Hello
I've been working on this project for a few weeks, mostly learning and reading the Tiva TM4C123GH6PM Microcontroller (SPMS377) data sheet.
I run into a problem I don't know the cause what is preventing the Timer_A from continuously counting and when it matches the preset value to reset and firing another interrupt then restart the timer..
this program is simple the RED led flashes via a delay loop, then the Green led to light when an interrupt occurs, but the interrupt only occurs once, and I don't know why, that's why I'm asking for your help.
I'm using CCS 5.4.0 windows XP
TIVA TM4C123GH6PM
Appreciate any help
Regards
Roman
====================================================================
#include <stdint.h>
#include "inc/tm4c123gh6pm.h"
extern void Timer0IntHandler(void);
void delay_sec(void);
volatile uint32_t ui32Loop;
volatile uint32_t nope;
#define SYSDIV 2
#define LSB 0
#define timer_int 0x00080000
#define red 0x0002
#define blue 0x0004
#define green 0x0008
//*****************************************************************************
//
// Blink the on-board LED.
//
//*****************************************************************************
int
main(void)
{
SYSCTL_RCC2_R |= SYSCTL_RCC2_USERCC2;
SYSCTL_RCC2_R |= SYSCTL_RCC2_BYPASS2;
SYSCTL_RCC_R &= ~SYSCTL_RCC_XTAL_M; // clear XTAL field
SYSCTL_RCC_R += SYSCTL_RCC_XTAL_16MHZ; // configure for 16 MHz crystal
SYSCTL_RCC2_R &= ~SYSCTL_RCC2_OSCSRC2_M; // clear oscillator source field
SYSCTL_RCC2_R += SYSCTL_RCC2_OSCSRC2_MO; // configure for main oscillator source
SYSCTL_RCC2_R &= ~SYSCTL_RCC2_PWRDN2;
SYSCTL_RCC2_R |= SYSCTL_RCC2_DIV400;
SYSCTL_RCC2_R &= ~SYSCTL_RCC2_SYSDIV2_M; // clear system clock divider field
SYSCTL_RCC2_R &= ~SYSCTL_RCC2_SYSDIV2LSB; // clear bit SYSDIV2LSB
SYSCTL_RCC2_R += (SYSDIV<<23)|(LSB<<22); // divide by (2*SYSDIV+1+LSB)
while((SYSCTL_RIS_R&SYSCTL_RIS_PLLLRIS)==0){};
SYSCTL_RCC2_R &= ~SYSCTL_RCC2_BYPASS2;
// Enable the GPIO port that is used for the on-board LED.
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
SYSCTL_RCGCTIMER_R = SYSCTL_RCGCTIMER_R0 + SYSCTL_RCGCTIMER_R1; // p334
// Do a dummy read to insert a few cycles after enabling the peripheral.
ui32Loop = SYSCTL_RCGC2_R;
// Enable the GPIO pin for the LED (PF3). Set the direction as output, and
// enable the GPIO pin for digital function.
GPIO_PORTF_DIR_R = 0x0E;
GPIO_PORTF_DEN_R = 0x0E;
ui32Loop = SYSCTL_RCGC2_R;
GPIO_PORTF_DATA_R &= ~(0x0E);
delay_sec();
// *************************************************************************
// timer 698
// *************************************************************************
TIMER0_CFG_R = TIMER_CFG_32_BIT_TIMER; // 00000000 p721
TIMER0_TAILR_R = 0x04FAF000; // 0x000186A; // load timer value 750
TIMER0_TAMR_R |= TIMER_TAMR_TAMR_PERIOD + TIMER_TAMR_TAMIE; // 0x2 723
TIMER0_IMR_R = TIMER_IMR_TATOIM; // set interupt 739
TIMER0_CTL_R = TIMER_CTL_TAEN; // enable the timer and start counting 731
// *************************************************************************
// interrupt
// *************************************************************************
NVIC_EN0_R = timer_int;
NVIC_ST_CTRL_R |= NVIC_ST_CTRL_INTEN;
while(1)
{
delay_sec();
GPIO_PORTF_DATA_R |= red;
delay_sec();
GPIO_PORTF_DATA_R &= ~(red);
GPIO_PORTF_DATA_R &= ~(green); // reset green INT may have set it
}
}
void delay_sec(void)
{
for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
{
}
}
void Timer0IntHandler(void)
{
GPIO_PORTF_DATA_R |= green;
NVIC_DIS0_R |= timer_int;
}
==================================================================================