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.

AM3359 SYS/BIOS and DMTIMER issues: impossibile to get it work...

Other Parts Discussed in Thread: SYSBIOS, AM3359

Hi all.

I'm trying ti configure DMtimer3 to call a function every 50 microseconds. 

I've followed this discussion: http://e2e.ti.com/support/arm/sitara_arm/f/791/p/194331/695180.aspx#695180 with no success

1) I've tried to use StarterWare DMTimer functions:

Hwi_Params_init(&hwiParams);
hwiParams.arg = 69;
hwiParams.priority = 3;
bk34HeaterHwi = Hwi_create( 69, my_dmtimer_hwi, &hwiParams, NULL );

/* Load the counter with the initial count value */
DMTimerCounterSet( SOC_DMTIMER_3_REGS, TIMER_INITIAL_COUNT );

/* Load the load register with the reload count value */
DMTimerReloadSet( SOC_DMTIMER_3_REGS, TIMER_RELOAD_COUNT );

/* Configure the DMTimer for Auto-reload and compare mode */
DMTimerModeConfigure( SOC_DMTIMER_3_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE );

Hwi_enableInterrupt( 69 );

DMTimerIntEnable( SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG );
DMTimerEnable( SOC_DMTIMER_3_REGS );


void my_dmtimer_hwi ( UArg arg )
{

DMTimerIntStatusClear( SOC_DMTIMER_3_REGS, (DMTIMER_INT_OVF_EN_FLAG | DMTIMER_INT_TCAR_EN_FLAG | DMTIMER_INT_MAT_EN_FLAG) );

return;

}

It worked for a while, then after a project rebuild command it stopped working, with execution stucked here:
          ti_sysbios_family_arm_a8_intcps_Hwi_vectors
I see a funny assembly instruction called "UndefinedLE" that endlessly jumps back to address 0x8041800:
I really can't explain why did it worked properly (tested with a nice and clean led toggle inside HWI function), then suddenly stopped after a project rebuild... 
Someone may call this "robustness" :-)
2) I've tried to use Timer as provided in HAL timer support:

Timer_Params timerParams;
Timer_Handle myTimer;

Timer_Params_init(&timerParams);
timerParams.period = 50;
timerParams.periodType = Timer_PeriodType_MICROSECS;
timerParams.arg = 1;
timerParams.startMode = Timer_StartMode_AUTO;
myTimer = Timer_create(3, my_dmtimer_hwi, &timerParams, NULL);

void my_dmtimer_hwi( UArg arg )
{

led_toggle()
return;

}

Same as previous:
This occurs *before* the timer initialization...
So I removed the DMTimer3ModuleClkConfig() function call in hardware initialization: It should be there because DMTimer3 module is not initialized by sysbios (is this statement correct?), but it seems that its presence cause that kind of problem. 
No ti_sysbios_family_arm_a8_intcps_Hwi_vectors exception occurs, but timer is not running and my_dmtimer_hwi  function is never called.

3) I do not want to consider Clock modules, because a small voice is telling me that it won't go...

AM3359, SYS/BIOS and CCS5 is the worse thing ever happened: simple tasks become messy, and no one knows how to face this complexity. 
Next life I'll chose Freescale :-)
  • Hello,

    There is one problem  in your HAL based implementation. The timer ID passed to Timer_create function is  3, however, id has to be 1 for DMTIMER3. See below given table ( Taken from SYS/BIOS help )

    I'm using the below given code to have a timer in my application and it is working perfectly for me.  You might want to give a try..

    Timer_Params timerParams;
    Timer_Handle myTimer;


    DMTimer3ModuleClkConfig();


    Timer_Params_init(&timerParams);
    timerParams.period = 50;
    timerParams.periodType = Timer_PeriodType_MICROSECS;
    timerParams.arg = 1;
    timerParams.extFreq.lo = 320000000;
    timerParams.extFreq.hi = 0;

    myTimer = Timer_create(1, myIsr, &timerParams, NULL); /* DMTIMER3 */

    if (myTimer == NULL) {
    System_abort("Timer create failed");
    }

    Regards,

    Shahid

  • Thank you for your reply.

    I've fixed the Timer id, but nothing changed.

    I can't find a rule or some kind of deterministic behavior: without powering DMtimer3 and without configuring a sysbios timer  module sometimes my application runs nicely, sometimes not.

    I've increased stack size (65535 bytes) but everything is always stuck here:

    ti_sysbios_family_arm_a8_intcps_Hwi_vectors

    Does someone know what (TF) is that? Why cpu sometime reach that? Why sysbios does not initialize it (assuming it's something that has to be initialized)?

  • Hi eugenio,

                       I'm running on the AM3359 as well and am having similar issues. My Timer_create function would implode until I put in the call to DMTimer3ModuleClkConfig(). So my code below will now compile, but it hangs during the Bios_Start(). Have you called the DMTimer3ModuleClkConfig()?

    John C.

        Timer_Params timerParams;
        Timer_Handle myTimer;

        Error_Block eb;
        Error_init(&eb);

        DMTimer3ModuleClkConfig();

        Timer_Params_init(&timerParams);
        timerParams.period        = 1000;
        timerParams.periodType    = Timer_PeriodType_MICROSECS;
        timerParams.arg            = 1;
        //timerParams.intNum        = 13;
        myTimer = Timer_create(1, timer3Isr, &timerParams, &eb);
        if (myTimer == NULL)
        {
            UARTprintf("Error creating Timer 3, error code %d\n", myTimer);
        }

  • Another community member was having issues with Timers but it turned out to be due to his GEL file.

    Please have a look at the post here, maybe the GEL file attached there has what you need:

    http://e2e.ti.com/support/embedded/bios/f/355/p/270589/946269.aspx#946269

    Steve

  • Today, Wednesday, June 12, 2013 at 10.47am is working.

    This is the init code:

    // /* This function will enable clocks for the DMTimer3 instance */
    DMTimer3ModuleClkConfig();


    Hwi_Params_init(&hwiParams);
    hwiParams.arg = 69;
    hwiParams.priority = 3;
    Hwi_create( 69, heater_hwi, &hwiParams, NULL );

    /* Load the counter with the initial count value */
    DMTimerCounterSet( SOC_DMTIMER_3_REGS, TIMER_INITIAL_COUNT );

    /* Load the load register with the reload count value */
    DMTimerReloadSet( SOC_DMTIMER_3_REGS, TIMER_RELOAD_COUNT );

    /* Configure the DMTimer for Auto-reload and compare mode */
    DMTimerModeConfigure( SOC_DMTIMER_3_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE );

    Hwi_enableInterrupt( 69 );

    DMTimerIntEnable( SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG );
    DMTimerEnable( SOC_DMTIMER_3_REGS );

    And this is the interrupt service routine:

    void heater_hwi ( UArg arg )
    {
    fpga_gpio_led_set( SERVICE_LED_BLUE_H20 ); // device specific stuff

    DMTimerIntStatusClear( SOC_DMTIMER_3_REGS, (DMTIMER_INT_OVF_EN_FLAG | DMTIMER_INT_TCAR_EN_FLAG | DMTIMER_INT_MAT_EN_FLAG) );
    fpga_gpio_led_reset( SERVICE_LED_BLUE_H20 ); // device specific stuff

    return;
    }

    After several trials I was not able to get the project working correctly, despite the fact that I had deleted all the code related to timer!

    So, I guessed that the issue was in Code Composer (or compiler, or linker), or in project's specific some configuration file. 

    I made a backup copy of header and source files for timer stuff, then deleted the project entirely, closed code composer, deleted any project file in workspace folder.

    Then, I relaunched code composer and imported a backup version of my project. After that, I added the files backed up earlier, compiled and now it works fine.

    No source code was modified: just backup some .C and .H files, and then add those files in a new project!

    In conclusion: there is something in ccs v5.2 that suddenly gets screwed up and, from that point on, a project is definitely corrupted. Please, someone of you at TI please report this bug. I can send you the backup copy of corrupted project, if you think this is useful to investigate the problem.

    Thank all those guys who gave me advices.

    PS: I suspect and fear that this problem will come out again in some imaginative and terrific way. 

  • Hey Steven,

                Thanks for the reply. Our system has been up and running on StarterWare for a while so there are no GEL files used. I took a brief look at the gel files and they seem to be related to Timer addresses and configuration so it does not appear that it is related to something in there. At this point it could just be system setup as I have also been fighting with tasks exploding because their stack is not big enough. The example code is great for getting started but once you go beyond that the documentation for SYS/BIOS is lacking (I think this in part is due to the various processors/platforms it runs on) and it makes it a much harder to tweak the system for proper operation.

    Thanks,

         John C.