Tested Timers 1 to 17 and all are working great in down counting mode

interrupts
key 3 years ago
parent 5cfbacc060
commit c68c8fd33d

@ -5,14 +5,31 @@
#include "ascii.h" #include "ascii.h"
#include "timer.h" #include "timer.h"
void timer_test(timerNo_t timer, pinNo_t pin)
{
timerInit(timer, 4000, 999, downCounting, counter);
timerSart(timer);
for(int i = 0; i < 10 ; i++)
{
while(!timerGetUpdateInterrupt(timer));
timerClearUpdateInterrupt(timer);
pinToggle(pin);
}
pinWrite(pin,0);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
uint8_t i = 0; uint8_t i = 0;
timerNo_t timers[MAX_TIMER_CHANNEL_COUNT] = {timer_1, timer_2, timer_3, timer_14, timer_16, timer_17};
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
timerInit(timer_1, 7999, 999, downCounting, counter);
timerSart(timer_1);
pinConfig(pinB3, output, pushPull, def_res, def_speed); pinConfig(pinB3, output, pushPull, def_res, def_speed);
pinConfig(pinA0, input, def_stage, pullDown, def_speed); pinConfig(pinA0, input, def_stage, pullDown, def_speed);
@ -41,11 +58,20 @@ int main(int argc, char *argv[])
pinWrite(pinB3,0); pinWrite(pinB3,0);
for (i = 0 ; i < MAX_TIMER_CHANNEL_COUNT; i++ )
{
print_Usart(usart2, const_cast<char *>("Testing Timer :"));
usartSendChar(usart2, i+48);
print_Usart(usart2, const_cast<char *>("\r\n"));
timer_test(timers[i], pinB3);
print_Usart(usart2, const_cast<char *>("Testing Completed \r\n\r\n"));
delayMs(100);
}
print_Usart(usart2, const_cast<char *>("All is working fine \r\n"));
while(1) while(1)
{ {
while(!timerGetUpdateInterrupt(timer_2));
timerClearUpdateInterrupt(timer_2);
pinToggle(pinB3);
} }
return 1; return 1;

Loading…
Cancel
Save