You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/libraries/examples/timer2_Interrupt_Blinki/main.c

66 lines
1.2 KiB

#include "delay.h"
#include "pin.h"
#include "deviceSetup.h"
#include "interrupt.h"
#include "timer.h"
void blinkiTask()
{
pinWrite(pinB3,1);
delayMs(10);
pinWrite(pinB3,0);
}
int main(int argc, char *argv[])
{
uint8_t i = 0;
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
pinConfig(pinB3, output, pushPull, def_res, def_speed);
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
intDisableAll();
intEnableAll();
//blinks 1 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 10 ; i++) {
delayMs(50);
pinToggle(pinB3);
delayMs(50);
}
pinWrite(pinB3, 0);
timerInitCounter(timer_2,(8E6/20E3)-1, 5000-1, upCounting);
//timerSetHz(timer_2, 1);
//TIM2->DIER = TIM_DIER_UIE;
timerEnableInterrupt(timer_2,TIM2_UPDATE);
intInit(TIM2_UPDATE, blinkiTask, 2);
intEnable(TIM2_UPDATE);
timerStart(timer_2);
/*
timerSetHz(timer_2, 10);
TIM2->DIER = TIM_DIER_UIE;
intEnable(TIM2_UPDATE);
timerStart(timer_2);
*/
while(1)
{
/*
delayMs(100);
pinToggle(pinB3);
delayMs(100);
*/
}
return 1;
}