UART only receiving one byte of data before sending all 0's.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

UART only receiving one byte of data before sending all 0's.

1,368件の閲覧回数
brendanmerna
Contributor IV

I'm using a MK22F51212 chip on a custom circuit board. The UART0 line is hooked up to a ORG1411 GPS and I'm trying to read NMEA strings out of the device and into a buffer.

I am following the demo project in the KSDK 2.0 driver_examples/uart/polling to initialize and read the UART data.

I am able to read the 8 bytes out of the buffer. This is the first 8 bytes sent by the GPS which I have confirmed is accurate based on the GPS data sheet. After that every read I make I only read 0's, this happens whether I'm reading a byte at a time or a whole 8 byte buffer.

Is there another step I need to do after a read? I'm using the UART_ReadBlocking function.

タグ(3)
0 件の賞賛
3 返答(返信)

932件の閲覧回数
brendanmerna
Contributor IV

Hey Robin,

Thanks for the suggestion! Looks like we are going to try to implement the edma interrupt method with a ring buffer. The polling must be causing some kind of overflow because we aren't reading fast enough. I'll let you know if this works.

-Brendan

0 件の賞賛

932件の閲覧回数
mjbcswitzerland
Specialist V

Hi Brendon

You can also get a complete solution for the K22 with half-buffer, full-buffer or free-running DMA reception (and/or Tx) on all UARTs by using the uTasker project. Is is used often for such work and so is proven and requires no further development.
Allows complete operation to be simulated (included DMA behavior) in VisualStudio and build with almost any IDE (KDS, MCUXpresso, UAR, Keil, Rowley, etc...).
Compatible with UART and LPUARTs on all devices (K, KL etc.) so no porting needed when chips are changed.

Free-running UART references:
https://www.youtube.com/watch?v=dNZvvouiqis&index=10&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q
https://www.youtube.com/watch?v=dNZvvouiqis&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=10

K22 references:
http://www.utasker.com/kinetis/FRDM-K22F.html
http://www.utasker.com/kinetis/TWR-K22F120M.html
http://www.utasker.com/kinetis/BLAZE_K22.html

UART guide: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

Regards

Mark

0 件の賞賛

931件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Brendan,

Would you please send the project to me so that I can test your project on FRDM-K22F or TWR-K22F120M board. And please send one frame data in hex from GPS.

The UART0 of K22F120M contains 8-entry transmit and 8-entry receive FIFOs, this helps to reduce the load of the core.

For example:

    config.rxFifoWatermark = 8;
    config.txFifoWatermark = 8;

    UART_ReadBlocking(DEMO_UART, &ch, 8);
    UART_WriteBlocking(DEMO_UART, &ch, 8);


Normally we will not use the polling example, maybe you can test these examples with interrupt.

uart SDK_2.2_TWR-K22F120M.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛