MS counter


#1

Hello,

I’m trying to do a counter of miliseconds and i can`t do it.
I’ve read in the documentation that the minimum sensibility is 1ms.

I want do a little soft that has to send a message saying “OK” every 5ms for afther do harders softs, but i couldnt. I’ve search in the forum but i doesn’t understand some answers that i’ve found. I have tried this but they didnt work :frowning:
Could anybody post and example of a soft that do something similar? :question:

Thank you :stuck_out_tongue:


#2

The minimum timer interval is 18.5ms. You can’t trigger events any faster than this.

You can use the TCU service to time smaller intervals or to capture events, but not trigger actions faster than 18.5ms.


#3

If i want send a message every 5ms, i can’t with the TCU??

My case is the next:

I want send a message and wait 5ms for send the next message, i’m not able for do this with my TCU??

Thank you,


#4

Looks like you can use the TCU to generate interrupts much faster. See the code below from the ADL user guide:

// TCU service handle 
s32 TCUHandle; 

// IRQ service handle
 s32 IrqHandle; 

// TCU Accurate timer configuration: periodic 5ms timer 
adl_tcuTimerSettings_t Config = { { 5, ADL_TCU_TIMER_UNIT_MS }, TRUE }; 

// TCU interrupt handler
bool MyTCUHandler (adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data )
{   
    // Check for Timer event 
    if ( Source == ADL_IRQ_ID_TIMER ) 
    {  // Trace event 
        TRACE (( 1, "Timer event" )); 
    } 
    return TRUE; 
} 

// Somewhere in the application code, used as event handlers 
void MyFunction1 ( void )
 {   
    // Subscribes to the IRQ service 
    IrqHandle = adl_irqSubscribe ( MyTCUHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 0, 0 ); 

    // Subscribes to the TCU service, in Accurate Timer mode 
    TCUHandle = adl_tcuSubscribe ( ADL_TCU_ACCURATE_TIMER, IrqHandle, 0, &Config, NULL ); 

    // Starts event generation 
    adl_tcuStart ( TCUHandle ); 
}

void MyFunction2 ( void )
 { 
    // Stops event generation, and gets remaining time 
    adl_tcuTimerDuration_t RemainingTimer ; 
    adl_tcuStop ( TCUHandle, &RemainingTimer ); 

    // Un-subscribes from the TCU service 
    adl_tcuUnsubscribe ( TCUHandle ); 
}

#5

Hello,

First of all, thank you for your answer.

In another hand, I tried this example code in my TCU WMP150 before (ADL_TCU_CAPTURE mode with handler notification) and it doesn’t work well because i’ve got this errors in my code:

when i do

IrqHandle=adl_irqSubscribe ( MyTCUHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 0, 0);

:arrow_right: i’ve got error -5 (ADL_RET_ERR_NOT_SUBSCRIBED)->service not subscribed

afther, when I do :

TCUHandle = adl_tcuSubscribe ( ADL_TCU_ACCURATE_TIMER, IrqHandle, 0,&Config, NULL );

:arrow_right: I’ve got the second error -7 (ADL_RET_ERR_BAD_HDL)-> bad handle.

I imagine that the second error is because I don’t have IrqHandle. but i don’t understand the first error, why can’t subscribe the irq?? Could you help me?? :question:

Thank you! :exclamation:


#6

Have you defined a stack size for both high level and low level interrupts? 3096 bytes should be fine.

If that doesn’t work, try the following:

adl_irqConfig_t IRQintConfig;

    // Set IRQconfiguration
    IRQintConfig.PriorityLevel = 0;
    IRQintConfig.Enable = TRUE;
    IRQintConfig.Options = ADL_IRQ_OPTION_AUTO_READ;

    // Subscribes to the IRQ service - low level interrupt
    IrqHandle = adl_irqSubscribeExt(pfk_ExtIntHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, &IRQintConfig);

#7

When you say that , do you refer to this?

// Low level handlers execution context call stack size
const u32 adl_InitIRQLowLevelStackSize = 1024;
// High level handlers execution context call stack size
const u32 adl_InitIRQHighLevelStackSize = 1024;

Is it correct? are the correct values (1024) or will i have to put (3*1024)?

Thank you


#8

I test the code declaring the stacks and it works well!!! :astonished:

with my declaration of the stacks it works well :wink:

Thank you :mrgreen:


#9

Excellent! :smiley: