Problem with Serial_LDD Component

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with Serial_LDD Component

491 Views
ricardcomas
Contributor III

Hi everyone, i'm using Serial_LDD component to use Modbus comunication, all works good, but, in the function interrupt "Serial_OnBlockReceive()", the first byte that have to receive from trace Modbus, don't arrive,for example, if somebody send modbus trace to my microcontroler, it doesn't get the trace, but if send again trace to my microcontroller, (2 times) it work correctly, why?¿ first time to receive bytes doesn't work, from 1 once, it work correct.

My microcontroller is MKE04Z128VLK

Thanks!

Labels (1)
0 Kudos
1 Reply

383 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Ricard Comas

What code did you place in this part? this event is called when the requested number of data is moved to the buffer, so you don't have to read here, it is more like a flag to indicate that read has finished.  For example, you can have:

main.c

...
volatile bool DataReceivedFlg = FALSE;
...


Error = AS1_ReceiveBlock(MySerialPtr, InpData, 1U);             /* Start reception of one character */

while (!DataReceivedFlg) { }


Event.c

extern volatile bool DataReceivedFlg;

void AS1_OnBlockReceived(LDD_TUserData *UserDataPtr)
{
  DataReceivedFlg = TRUE;  /* Set DataReceivedFlg flag */
}

You could check the "Help on component" option for reference.

Hope this could help.

Best regards

Jorge Alcala

0 Kudos