UART receive in twrk65f180m missing bytes?

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

UART receive in twrk65f180m missing bytes?

926 Views
viveksrinivasan
Contributor I

Hi everyone,

I'm using the following board and OS,

                              Board : twrk65f180m

                              OS     :  MQX

I'm trying to communicate with the Bluetooth chip. I don't know how many bytes I will be receiving. For example this is my Tx and Rx bytes.

                                   Tx          -      0x01 0x03 0x0c 0x00

                                   Rx          -      0x04 0x0E 0x04 0x01 0x03 0x0c 0x00

The receive bytes will come together and there are no delays in between them. When I try to read them one by one like below

                              *lengthRead = _io_read((MQX_FILE_PTR)handle, (void*)buf, (_mqx_int) 1);

It just reads the first byte and then the next time it goes and waits for the next byte. Wheras there should be remaining 6 bytes that it should read. It seems like it has no buffer.

But when I try to read them all at once like below.

                              *lengthRead = _io_read((MQX_FILE_PTR)handle, (void*)buf, (_mqx_int) 7);

It returns all the 7 bytes without any issue.

I'm using ittyd to communicate with the bluetooth chip. I've even set the buffer size to a maximum of 256 bytes.

#define BSPCFG_SCI3_QUEUE_SIZE             256

Can anyone tell me why can't I read those bytes one by one? If there is a buffer all those bytes should be stored and I can retrieve those bytes the next time right?

Also, I'm using two UART's for my application ittyc (default) and ittyd.

Your help is much appreciated. Thank you.

Regards,

Vivek

Tags (3)
0 Kudos
4 Replies

510 Views
soledad
NXP Employee
NXP Employee

Hello Vivek,

I got the below answer from David E Seymour, Please let me know if this helps,

Regards

Soledad

Hi Vivek,

I setup my MQX4.2 for the twrk65f180m to have the default (ITTYC) UART operate in a non-blocking mode since I was just using the default UART interface to send and receive characters to the terminal window.

In twrk65f180m.h I made following change:

#ifndef BSP_DEFAULT_IO_OPEN_MODE

//DES #define BSP_DEFAULT_IO_OPEN_MODE          (void *) (IO_SERIAL_XON_XOFF | IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO)

  #define BSP_DEFAULT_IO_OPEN_MODE        (void *) (IO_SERIAL_NON_BLOCKING | IO_SERIAL_XON_XOFF |IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO) //DES added IO_SERIAL_NON_BLOCKING

#endif

For some unknown read I had to modify the serl_int.c at line 187 as follows:

      if (result == MQX_OK && ((_mqx_uint)flags & IO_SERIAL_NON_BLOCKING)//DES When I have flag set to IO_SERIAL_NON_BLOCKING it returns MQX_INVALID_PARAMTER???
          & (_mqx_uint)flags& (IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO | IO_SERIAL_XON_XOFF)) {//DES should && (_mqx_uint)flags.... be & (_mqx_uint)flags ???

        result = MQX_INVALID_PARAMETER;

Attached is my modified hello.c code from hello2 that is testing the UART interrupt receive buffer capability.  Default buffer size used of 64 byes.

If the code runs, then you can enter characters in the terminal windows and they get placed into the buffer.

If you enable a breakpoint at line 97 _time_delay(200); , then you can set the "lengthRead" variable to "4".  Now disable the breakpoint at line 97.  This will enable the code to read from the UART Rx Interrupt Buffer (fifo) until no more characters are present.  If you are fast to type you can add more character into the buffer before it completes.

Not sure this helps or hurts.  Let me know.

Regards,

David

0 Kudos

510 Views
viveksrinivasan
Contributor I

Hi Soledad,

Than you so much for your response. Please give me a couple of days as I'm busy with some work at the moment. I will get back to you by the end of this week. Once again thank you so much for your help.

Regards,

Vivek

0 Kudos

510 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Vivek,

Can you please submit a Service request at www.freescale.com/support please?

Best regards,

Carlos

0 Kudos

510 Views
viveksrinivasan
Contributor I

Hi Carlos,

I have submitted a service request. Thank you.

Regards,

Vivek

0 Kudos