asem84
March 23, 2012, 12:44pm
1
Hello,
I’m trying to do a periodically communication with the SPI bus.
I want send four differents message every 100 ms, with the condition that if i have finished to send a message, i will have to wait 5ms for send the next message. Receive message i have implemented with interruptions, but send message i don’t have idea. I think that adl_tmrSubscribe funtion is not the solution, because i couldn’t control the 5 ms between messages sended.
Have someone any idea? Exist another function better for me?
Thank you
Hi,
TCU timer can be used. Check the post [url]https://forum.sierrawireless.com/t/ms-counter/5539/6 ] for some details.
asem84
April 11, 2012, 11:19am
3
Thank you paruthiv,
I have one doubt,
// 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” ));
/*I write in the SPI */
adl_busWrite(spi_handler, &access_config, len , tx_buffer);
}
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 );
}
theoretically, with this code, I will write in the SPI bus every 5ms. Is this assumption correctly:?: ( look MyTCUHandler function )
Thank you
asem84
April 12, 2012, 10:49am
4
I’ve tested the code and my assumption is correct
with the code that I posted before, i’m writing every 5ms