STM32F4 - Systick - Delay_us

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
oth_florian
Newbie
Posts: 1
Joined: Wed Apr 27, 2016 5:31 pm

STM32F4 - Systick - Delay_us

Post by oth_florian » Tue Mar 14, 2017 9:49 am

Hi everybody,
I've playing a little bit with the STM32F4 Discovery Board and Erika. I found the function call

Code: Select all

EE_systick_delay_us
and want to use it. As a template, I use the STM32_io_toggle template, copy it.I change the TaskIOToggle Task and make busywaiting in there, just Activating the Task via ActivateTask and don't use the Alarm.
The Task is looking like

Code: Select all

TASK(TaskIOToggle)
{
	static EE_UINT8 act = 0;
	while(1){
		if(act++%2)
			GPIO_SetBits(GPIOD, GPIO_Pin_12);
		else
			GPIO_ResetBits(GPIOD, GPIO_Pin_12);
		EE_systick_delay_us(200);
	}
}
The problem is: The delay function does not delay 200us, just about 4.8us. And it don't make any difference if I change the value to e.g. 2000 or 10000. I looked into the code and ... don't understand why the author playing around with integer underflows and the make modulo. Why don't just make the absolut value of the actual time and the start time and check for being less than ticks, e.g.

Code: Select all

abs(start, time) < ticks
(writing an own abs function is not so much work).
The code I refer is

Code: Select all

	      
while (((EE_systick_get_value() - start) % NVIC_ST_RELOAD_M)  < ticks){
     ; /* wait */
}
Just to point out: The original source does not work for me!

Post Reply