Other Parts Discussed in Thread: LM3S811
I am doing a blinky led using Timer Time-Out. Although I follow the instructions in the datasheet, I don't know why this program doesn't work. I guess that this
condition " (TIMER0_RIS_R & 0x01) == 1 " is fault so that the LED doesn't blink. Can anyone help me pls!!!
int main()
{
//Set the system clock to 8MHZ
SysCtlClockSet (SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
//Enable Timer0
SYSCTL_RCGC1_R = SYSCTL_RCGC1_TIMER0;
//Disable Timer0 for config
TIMER0_CTL_R &= ~0x01;
//Choose 32bit Timer
TIMER0_CFG_R |= 0x00;
//Choose periodic mode
TIMER0_TAMR_R |= 0x02;
//Load the value of 4,000,000
TIMER0_TAILR_R |= 0x3D0900;
//Star the Timer0
TIMER0_CTL_R |= 0x01;
//=============================================================//
// Enable GPIO //
//=============================================================//
// Enable the GPIO port F for the on-board LED and SW2:
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
//Enable the GPIO pin for the LED(bit 0)
//Set the direction LED(bit 0)- OUTPUT
GPIO_PORTF_DIR_R = 0x01;
//Enable the GPIO pins:
GPIO_PORTF_DEN_R = 0x01;
while(1) {
if ( (TIMER0_RIS_R & 0x01) == 1) {
TIMER0_ICR_R |= 0X01;
// TIMER0_CTL_R &= ~0x01;
GPIO_PORTF_DATA_R ^= 0X01;
// TIMER0_CTL_R |= 0x01;
}
}
}