Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL
Hello,
I'm newbie with Tiva C microcontrollers. And since I don't want to use TivaWare libraries, I had to use the tm4c123gh6pm library. So now I'm doing some interrupts and I have stumbled on a dead end. There must be some sort of mistake when handling interrupts but I cannot find it. So, any help would be very very welcome.
Thanks!
#include "tm4c123gh6pm.h"
#include <stdint.h>
#define FLAG_NONE 0x0
#define FLAG_TOGGLE_LED 0x1
volatile uint8_t flags = FLAG_NONE;
uint32_t timer = 0;
interrupt void IntDefaultHandler(void){
flags = FLAG_TOGGLE_LED;
GPIO_PORTF_DATA_R ^= 0x2;
TIMER0_ICR_R |= 0x1; // reset timer
}
int main(void)
{
SYSCTL_RCGCGPIO_R |= 0x20; //GPIO REGISTERS
GPIO_PORTF_DIR_R |= 0xE;
GPIO_PORTF_DEN_R |= 0xE;
GPIO_PORTF_DATA_R |= 0x2;
// TIMER
SYSCTL_RCGCTIMER_R |= 0x1; // enable timer A, page 338
TIMER0_CTL_R &= ~0x1;
TIMER0_CFG_R |= 0x00000000;
TIMER0_TAMR_R |= 0x2; // periodical
TIMER0_TAMR_R &= ~(1<<4); // count from X to 0
TIMER0_TAILR_R = 0x7A1200; // count from 8000000 (0,5 sec)
TIMER0_IMR_R |= 0x1; //enable interrupt (TIMER0 time-out)
NVIC_EN1_R |= 0x8; // enable interrupt in NVIC register
TIMER0_CTL_R |= 0x1; //enable timer, start counting
while(1){
timer=TIMER0_TAR_R;
if(flags == FLAG_TOGGLE_LED){
GPIO_PORTF_DATA_R ^= 0x2;
flags = FLAG_NONE;
}
}
}