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.

关于tm4c1294的rtos中timer的问题

Other Parts Discussed in Thread: TM4C1294NCPDT

我采用的是tm4c1294ncpdt芯片,想用ti-rtos中的timer模块来定时1s实现led的闪烁,period我设置的是1000000,单位是微妙,但是结果虽然LED闪烁,但我调用timer_getperiod得到的是120000000,下面是我的源码和结果,请帮忙分析一下。

#include <xdc/std.h>
#include <xdc/runtime/System.h>
//#include <ti/sysbios/family/arm/m3/Hwi.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Timer.h>
#include <xdc/runtime/Error.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>

/* Example/Board Header files */
#include "Board.h"

UInt FLAG=0;
Timer_Params timerParams;
Timer_Handle timer0;
Void myIsr(UArg arg0)
{  
	FLAG=!FLAG;
    if(FLAG==0)
	{GPIO_write(Board_LED0, Board_LED_ON);}
    else
    {GPIO_write(Board_LED0, Board_LED_OFF);}
    System_printf("Current period = %d\n", Timer_getPeriod(timer0));
    System_printf("%d\n",FLAG);
    System_flush();
}



int main(void)
{

    Board_initGeneral();
    Board_initGPIO();
    Error_Block eb;
    Error_init(&eb);
    Timer_Params_init(&timerParams);
    timerParams.period = 1000000;
    timerParams.periodType = Timer_PeriodType_MICROSECS;
    timerParams.arg = 1;
    timer0 = Timer_create(Timer_ANY, myIsr, &timerParams, &eb);
    if (timer0 == NULL)
    {
    System_abort("Timer create failed");
    }


    System_flush();



    /* Start BIOS */
    BIOS_start();

    return (0);
}

下面是运行结果