Oct 16, 2019
12:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 16, 2019
12:42 AM
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);
}
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);
}
- Tags:
- IFX
1 Reply
Oct 22, 2019
07:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 22, 2019
07:28 AM
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.
/*
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.