Part Number: CC2642R
Tool/software: TI C/C++ Compiler
Dear All
I'm using the CC2642R with UART, I need to measure accurately when the UART Rx data arrive.
I tried to call Seconds_getTime() in the UART Rx callback but it seems to cause problems, the timestamp I obtain from Seconds_getTime in release mode does not seem correct.
When I try to debug with printf() the timestamp I obtain, the execution hangs.
I suspect this function cannot be called from the interrupt, is there a way to solve this ?
My code is as follow :
void MidiUART_readCallBack(UART_Handle handle, void *ptr, size_t size)
{
if(size > 0)
{
Seconds_Time ts; Seconds_getTime(&ts);
uint32_t currentTimeStamp = ((ts.secs & 15) * 1000) + (ts.nsecs / 1000000);
uint32_t timePassedSinceLatestRxMidi = currentTimeStamp - latestRxMidiTimeStampReceived;
//Display_printf(dispHandle, currentLogLine++, 0, "ts %u", currentTimeStamp);
latestRxMidiTimeStampReceived = currentTimeStamp;
.......
Semaphore_post(hSemaphoreMidiRx);
// Trigger next RX Midi read
UART_read(uartMidi, &lowLevelRxBuff[0], LOW_LEVEL_MIDI_BUFF_SIZE);
}
void midiRxTask(UArg a0, UArg a1)
{
Semaphore_Params sParams;
Semaphore_Params_init(&sParams);
sParams.mode = Semaphore_Mode_COUNTING; // Semaphore_Mode_BINARY;
Semaphore_construct(&semaphoreMidiRx, 0, &sParams);
hSemaphoreMidiRx = Semaphore_handle(&semaphoreMidiRx);
// trigger first read
UART_read(uartMidi, &lowLevelRxBuff[0], LOW_LEVEL_MIDI_BUFF_SIZE );
while(1)
{
// Wait until something was received
Semaphore_pend(hSemaphoreMidiRx, BIOS_WAIT_FOREVER);
......
}
}
I'm using UART PARTIAL READ.
Thanks for any tip
Jerome