打印

LM3S9B96进不了定时器中断,程序贴出来了,各位帮我看看

[复制链接]
2078|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
phan02|  楼主 | 2010-12-8 22:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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)
    {
    }
  
}

相关帖子

沙发
yiyanzhong| | 2012-11-5 23:23 | 只看该作者
要想进中断得对starup.s这个文件做出部分更改

使用特权

评论回复
板凳
yiyanzhong| | 2012-11-5 23:23 | 只看该作者
要想进中断得对starup.s这个文件做出部分更改

使用特权

评论回复
地板
阿南| | 2012-11-6 09:23 | 只看该作者
查看一下定时器是否已经开始工作,对应的中断屏蔽位是否打开,在中断入口设置断电查看是否已经产生中断,查看一下中断是否因中断向量表没有安装而跑飞。。。等

使用特权

评论回复
5
123AW456| | 2014-7-19 14:45 | 只看该作者
寄存器版本,表示看不懂啊。。。。。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

8

帖子

1

粉丝