XMC 1100 H bridge kit 2 go delay function problem in DAVE

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User17857
Level 3
Level 3
First like received
Hello,

I want to use delay function in dave to blink a led periodically. My code is below but I dont know why it not working.
I think we have a problem with the initial configurations. Any help would be appreciated. This code below should toggle the led. But the led is always high.

Kind regards,
Ozkan.

#include
#define TIMER_DELAY_MUL_FACTOR 100000U // Converts micro seconds to milli seconds with multiplication factor for
// TIMER_GetInterruptStatus().


void TIMER_Delay(uint32_t);
int main(void)
{
DAVE_STATUS_t init_status;
TIMER_STATUS_t status;
uint32_t delay_val; // delay value in terms milli seconds

init_status = DAVE_Init(); // TIMER_Init(&TIMER_0) will be called from DAVE_Init()

TIMER_ClearEvent(&TIMER_0);

if(init_status == DAVE_STATUS_SUCCESS)
{
delay_val = 1000; // 1000 milli seconds

TIMER_Delay(delay_val);
}

while(1)
{
TIMER_Delay(1000);
DIGITAL_IO_ToggleOutput(&LED1);
}
return 1;
}

void TIMER_Delay(uint32_t delay_val)
{
uint32_t delay_cnt;

delay_cnt = delay_val * TIMER_DELAY_MUL_FACTOR;

TIMER_SetTimeInterval(&TIMER_0,delay_cnt);

TIMER_Start(&TIMER_0);

while(!TIMER_GetInterruptStatus(&TIMER_0));

TIMER_Stop(&TIMER_0);
}
0 Likes
1 Reply
User18085
Level 1
Level 1
Greetings. If you use the code as I have edited, you can get the result you want. All you need to do after the while loop

/*
void Timetick_Handler(void)
{
TIMER_ClearEvent(&TIMER_0);
}
*/

will add the function and run the code.
We can say that this function is a cleanup function that we use for each event we create.
Note: You need to add the interrupt app and configure the signal with the timer.

The following illustrations show how the configurations should be.
Best regards.

3833.attach 3834.attach

3839.attach 3835.attach

3836.attach 3837.attach

3838.attach 3840.attach
0 Likes