Part Number: TM4C123GH6PM Tool/software: Code Composer Studio Hello, I am trying to generate a periodic intereupt to drive the blue LED (make it blink every second).
I have initialized the clock to 12.5 MHZ and therefore calculated a reload value according to it so the systick ticks "reload value" times before generating an interrupt.
In addition i have created a handler to service the interrupt where i ask it to blink. I wanted to ask if this is right, I am waiting for my board but in the meanwhile I was able to code this,
i was hoping if someone could point out any errors as i dont have a board yet so i cannot test it. Below is the code for reference. Thanks #include <stdint.h> #include <stdbool.h> #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "inc/tm4c123gh6pm.h" void systick_initialize(unsigned long reload_value) { NVIC_ST_CTRL_R = 0; // disable systick NVIC_ST_RELOAD_R=reload_value ; // systick interupt time period= (SysTick_load+1)* Clock period NVIC_ST_CURRENT_R = 0; NVIC_SYS_PRI3_R = NVIC_SYS_PRI3_R&0x00FFFFFF; // priority 0 NVIC_ST_CTRL_R = 0x07; // enable systick } void systick_handler(void) { if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0); } else { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4); } } int main(void) { systick_initialize(12499999); SysCtlClockSet(SYSCTL_SYSDIV_16|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); // clock at 12.5MHZ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4); GPIO_PORTF_LOCK_R = 0x4C4F434B; GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); // enable F4's pullup, the drive strength won't affect the input GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); }