LM3S9B96进不了定时器中断,程序贴出来了,各位帮我看看,谢谢先!
//*****************************************************************************
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "inc/lm3s9b96.h"
#include "driverlib/gpio.h"
#include "inc/hw_memmap.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
//*****************************************************************************
#define RS485_U1_BASE GPIO_PORTG_BASE
#define U1RX_PIN GPIO_PIN_0
#define RS485_U2_BASE GPIO_PORTC_BASE
#define U2RX_PIN GPIO_PIN_6
void RS485sampledatainitial(void);
void Timer0Initial(void);
void
RS485sampledatainitial(void)
{
volatile unsigned long ulLoop;
//
// Enable the GPIO port that is used for the on-board LED.
//
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOC | SYSCTL_RCGC2_GPIOG;
//
// Do a dummy read to insert a few cycles after enabling the peripheral.
//
ulLoop = SYSCTL_RCGC2_R;
//
//U2RX
GPIO_PORTC_DIR_R &= ~(0x40);
GPIO_PORTC_DEN_R |= 0x40;
//U1RX
GPIO_PORTG_DIR_R &= ~(0x01);
GPIO_PORTG_DEN_R |= 0x01;
// The Initial handler for the timer0 .
Timer0Initial();
}
//*****************************************************************************
//
// The Initial handler for the timer0 .
//
//*****************************************************************************
void
Timer0Initial(void)
{
//
// Enable the peripherals used by this example.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//
// Enable processor interrupts.
//
IntMasterEnable();
//
// Configure the two 32-bit periodic timers.
//
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
//
// Set the Timer0A load value to 1s.
//
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet());
//HWREG(TIMER0_BASE+0x18) |= 0x00000001;
//
// Configure the Timer0A interrupt for timer timeout.
//
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//
// Enable the Timer0A.
//
TimerEnable(TIMER0_BASE, TIMER_A);
//
// Enable the Timer0A interrupt on the processor (NVIC).
//
IntEnable(INT_TIMER0A);
}
//*****************************************************************************
//
// The interrupt handler for the timer0 interrupt.
//
//*****************************************************************************
void
Timer0IntHandler(void)
{
//
// Clear the timer interrupt.
//
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//
// Indicate that a timer interrupt has occurred.
//
//GPIOPinRead(RS485_U1_BASE, U1RX_PIN);
//GPIOPinRead(RS485_U2_BASE, U2RX_PIN);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6,
GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_6) ^ GPIO_PIN_6);
TimerEnable(TIMER0_BASE,TIMER_A);
}
int
main(void)
{
//
// Set the clocking to run directly from the PLL.
//
//SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
//SYSCTL_OSC_MAIN);
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Initialize the device pinout appropriately for this board.
//
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOB);
GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_6, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(GPIO_PORTB_BASE,GPIO_PIN_6,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6, 1);
//RS485sampledatainitial();
Timer0Initial();
//
// Loop forever while the timers run.
//
while(1)
{
}
}
|