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.

LP-AM243: The clock systick on AM243x-LP

Part Number: LP-AM243


Hello

I need to use the Clock Tick in AM243x to generate a 1ms tick, now I have configure it in "example.syscfg". I also write a clock callback and clockParams to put in clockObj as following code

uint32_t gOneShotCount = 0;
uint32_t gPeriodicCount = 0;
void myClockCallback(ClockP_Object *obj, void *arg)
{
    uint32_t *value = (uint32_t*)arg;
    (*value)++; /* increment number of time's this callback is called */
}
ClockP_Params clockParams;
ClockP_Object clockObj;
ClockP_Params_init(&clockParams);
clockParams.timeout = ClockP_usecToTicks(100*1000);
clockParams.period = clockParams.timeout;
clockParams.start = 1;
clockParams.callback = myClockCallback;
clockParams.args = &gPeriodicCount; /* pass address of counter which is incremented in the callback */
ClockP_construct(&clockObj, &clockParams);
When I debug the project, I found it can enter into the interrupt ClockP_timerTickIsr(void *args)   and do myClockCallback only once, next time enter into ClockP_timerTickIsr(void *args) I check the code with single step and find obj->timeout is changed to 1879626760, it cause that it will not enter into myClockCallback, so I don't know the reason.
Could someone can help me? thank you
  • Hi Matt,

    For your use case, it is better to use TimerP instead of the ClockP. The ClockP is providing the system clock (heartbeat using Timer8). There are 7 more timers can be used by users. Here is the code section for TimerP setup (empty.c):

    int myTimerCallbackCount = 0;
    void myTimerCallback(void)
    {
        myTimerCallbackCount++;
    }

    void empty_main(void *args)
    {
        TimerP_Params timerParams;

        /* Open drivers to open the UART driver for console */
        Drivers_open();
        Board_driversOpen();

        DebugP_log("All tests have passed!!\r\n");

        TimerP_Params_init(&timerParams);
        timerParams.inputPreScaler = CONFIG_TIMER0_INPUT_PRE_SCALER;
        timerParams.inputClkHz = CONFIG_TIMER0_INPUT_CLK_HZ;
        timerParams.periodInUsec = CONFIG_TIMER0_USEC_PER_TICK;
        timerParams.oneshotMode = 0;
        timerParams.enableOverflowInt = 1;
        TimerP_setup(gTimerBaseAddr[CONFIG_TIMER0], &timerParams);
        TimerP_start(gTimerBaseAddr[CONFIG_TIMER0]);

        while (1)
        {
        }

        Board_driversClose();
        Drivers_close();
    }

    Here is the example.syscfg screen capture:

    I have tested it on AM243x LP. It works fine.

    Best regards,

    Ming

  • hello, ming

    Thanks for your help, I will test it