This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

急!!!!定时器的配置

Other Parts Discussed in Thread: EK-TM4C1294XL

//配置一个32位的定时器,不知道下面的问题出在哪
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);//ʹÄÜTIMER0Ä£¿é
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);//ÅäÖÃTimer0Ϊ32λÖÜÆÚ¶¨Ê±Æ÷
TimerLoadSet(TIMER0_BASE, TIMER_A,1250000UL);//

  • 1.你的主时钟的选择

    2.你的中断允许了没

    3.你的问题是什么呢?定时器哪里有问题了

    4.你的MCU型号是什么

    给你一段官方的例程

        //
        // Enable lazy stacking for interrupt handlers.  This allows floating-point
        // instructions to be used within interrupt handlers, but at the expense of
        // extra stack usage.
        //
        ROM_FPULazyStackingEnable();
    
        //
        // Set the clocking to run directly from the crystal.
        //
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                           SYSCTL_XTAL_16MHZ);
    
        //
        // Initialize the UART and write status.
        //
        ConfigureUART();
    
        UARTprintf("\033[2JTimers example\n");
        UARTprintf("T1: 0  T2: 0");
    
        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
        //
        // Enable the GPIO pins for the LED (PF1 & PF2).
        //
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);
    
    
        //
        // Enable the peripherals used by this example.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    
        //
        // Enable processor interrupts.
        //
        ROM_IntMasterEnable();
    
        //
        // Configure the two 32-bit periodic timers.
        //
        ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
        ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
        ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet());
        ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() / 2);
    
        //
        // Setup the interrupts for the timer timeouts.
        //
        ROM_IntEnable(INT_TIMER0A);
        ROM_IntEnable(INT_TIMER1A);
        ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
        ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    
        //
        // Enable the timers.
        //
        ROM_TimerEnable(TIMER0_BASE, TIMER_A);
        ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    
        //
        // Loop forever while the timers run.
        //
  • ROM_FPULazyStackingEnable();//这个是什么?

    你说的我都配置了,没放上去。MCU是TM4C1294XL

  • ROM_FPULazyStackingEnable()这个函数是设置FPU的。详细信息请参考库函数文档。

    关于TM4C129x的定时器,请参考例程:

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c1294xl\timers