Looking for 9-bit driver for slave node on RS485 net

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

Looking for 9-bit driver for slave node on RS485 net

667 Views
davenadler
Senior Contributor I

Background

RT1024 is a slave node on a 9-bit RS485 network. As usual in these networks, 9-bit flags an address byte, messages are variable length, and master sends messages without gaps (no idle during transmission). When the slave receives a message, its necessary to reply promptly. For acceptable performance, ideally the driver:

  1. waits for its address to show up on the net (line in receive mode)
  2. receives 8-bit values via DMA (9-bit should be zero for payload after address byte)
  3. when the line goes idle (~1 character time) stops receive DMA and generates an interrupt
  4. ISR sets line to transmit mode and transmits response (typically prepared data sitting ready to go, ie sensor readings) via DMA
  5. ISR processes received data from master (typically post it in a queue, callback, whatever)
  6. when DMA transmission completes, line is returned to receive mode

Ideally, only one interrupt (on completion of message reception); everything else handled via DMA.

Questions

  1. Can the LPUART/eDMA do this? Or does LPUART/eDMA require additional interrupts?
  2. Has anybody got code for this? I hate to keep re-inventing the wheel.
    The SDK samples do not cover this use case (only a very simplistic 9-bit example without DMA)...
    AN12679 also does not seem to cover this use case.

Thanks in advance!
Best Regards, Dave

PS: @Omar_Anguiano ?

Labels (1)
Tags (3)
0 Kudos
Reply
2 Replies

604 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello,
I hope you are well

1. Yes, it is possible to implement this, on the AN you referenced there is a similar example that can be adapted to your needs: 

Omar_Anguiano_0-1716921464539.png

 

2. Unfortunately, there is no specific example of a 9-bit Uart with DMA however you can make these changes to the DMA example: 
Solved: mx rt 1020 send 9bit over DMA - NXP Community

Best regards,
Omar

0 Kudos
Reply

399 Views
davenadler
Senior Contributor I

@Omar_Anguiano- I have studied application note AN12679, but there are very serious problems with the code provided.
A few of the important ones:

  1. Before LPUART_SendEDMA calls the user-supplied callback function, it internally waits first for the DMA completion interrupt, then LPUART's transmission complete interrupt. In the AN12679 code, the LPUART transmission complete processing is repeated. Apparently the author did not understand LPUART_SendEDMA already does this. The RS485 transmit-mode switching can be handled in the EDMA callback without messing with LPUART interrupt.
  2. LPUART_SendEDMAdocumentation is quite poor and fails to make this clear, see:
    https://mcuxpresso.nxp.com/api_doc/dev/3317/a00047.html#ga24c9dff9f142243ed5ffb3112a356386 
  3. If an application overrides the LPUART ISR using LPUART_SendEDMA, it must call LPUART_TransferEdmaHandleIRQ after catching the transmission-complete interrupt. Without this call, the LPUART EDMA transfer status remains busy, and the next attempt to transmit will fail. As I found out...
  4. The EDMA callback is incorrectly named with a comment explaining it is not what the name implies. It should be named EDMA_UserCallback.
  5. I could go on...

It would be great if NXP could clean up this application note's software!
This kind of stuff wastes a great deal of customer time.
Thanks!
Best Regards, Dave

0 Kudos
Reply