Other Parts Discussed in Thread: SYSCONFIG, SYSBIOS
Hi folks,
I have a CC2642R1 (SimpleLink SDK 5.10) chatting with an external UART Device via the UART2 driver.
- TXs are less than 32 bytes and write flawlessly.
- RXs are about 70 bytes long and I can only verify reconstruction of the first 6 values.
I believe that one of my settings is wrong or I my method for UART_READ is incorrect. There appears to be a bug in the UART2 driver which I am waiting for a TI Driver Expert to try to identify and resolve but that should not prevent me from fixing whatever is wrong with the buffer.
Thank you,
Ken
SysConfig:
Global Variables:
// Read Buffers const size_t RX_Size = 128; static uint8_t RX_COM1 [RX_Size];
Interface Initialization and Task:
// Initialize the UART driver. UART2_Params_init(&COM_Params); COM_Params.readMode = UART2_Mode_CALLBACK; COM_Params.readCallback = callbackFxn_read; COM_Params.dataLength = UART2_DataLen_8; COM_Params.stopBits = UART2_StopBits_1; COM_Params.parityType = UART2_Parity_NONE; COM_Params.baudRate = 115200; COM_1 = UART2_open(UART2_Device1, &COM_Params); if (COM_1 == NULL) { Display_printf(dispHost, 0, 0, "COM Task: Failure to Initialize\n"); while(1); } else { Display_printf(dispHost, 0, 0, "COM Task: Initialized Successfully\n"); } while(1) { memset(RX_COM1, 0x00, sizeof(RX_COM1)); size_t numBytesRead = 0; status = UART2_read(COM_1, &RX_COM1, RX_COM1, numBytesRead); if (status != UART2_STATUS_SUCCESS) { /* UART2_read() failed */ Display_printf(dispHost, 0, 0, "COM: Failed to Read\n"); } // Wake up the OS task Semaphore_pend(Semaphore_handle(&comTaskSemaphore), BIOS_WAIT_FOREVER); RX_Handler(RX_COM1,numBytesRead); WaitingForRX = false; // Flush the 32 byte Rx buffer internal to the UART2 Driver. UART2_flushRx(COM_1); }
Functions:
/* * ======== callbackFxn ======== */ void callbackFxn_read(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status) { if (status != UART2_STATUS_SUCCESS) { /* RX error occured in UART2_read() */ Display_printf(dispHost, 0, 0, "COM: Failed to Read\n"); } // Wake up the OS task Semaphore_post(Semaphore_handle(&comTaskSemaphore)); } /* * =========================================================================== * Serial Port Interface * =========================================================================== */ void RX_Handler(uint8_t* RX_Buffer, size_t numBytes){ // Debug Code Display_printf(dispHost, 0, 0, "COM: UART Received %u bytes!", numBytes); uint16_t loop; for (loop = 0; loop <= 255; loop++){ if (RX_Buffer[loop] != 0x00){numBytes++;} } Display_printf(dispHost, 0, 0, "COM: Read Received %u bytes!\n\n",numBytes); }
Console Output:
[Cortex_M4_0] Host Display Initialized! Tasks Initializing: COM Task: Initialized Successfully COM: Requesting Data Packed Message size: 6 COM: Sent 6 bytes COM: UART Received 0 bytes! COM: Read Received 54 bytes! COM: Requesting Data Packed Message size: 6 COM: Sent 6 bytes COM: UART Received 0 bytes! COM: Read Received 54 bytes!
Buffer Comparison:
I wrote down the values I observed on my oscilloscope and the values from the Buffer as seen in CCS 10.3.0
This corresponds with the above console output. The 54 Bytes read are likely the result of reading PAST the buffer (size 128 vs loop size 256).
- GREEN values indicate confirmed Read Success
- YELLOW values indicate unconfirmed Read
- RED values indicate confirmed Read Failure
Oscilloscope RX | UART RX Buffer | |
00 | 0x02 | 0x02 |
01 | 0x41 | 0x41 |
02 | 0x04 | 0x04 |
03 | 0x01 | 0x01 |
04 | 0x33 | 0x33 |
05 | 0xFD | 0xFD |
06 | 0x55 | 0x55 |
07 | 0x00 | 0x00 |
08 | 0x00 | 0x00 |
09 | 0x00 | 0x00 |
10 | 0x00 | 0x00 |
11 | 0x00 | 0x00 |
12 | 0x00 | 0x00 |
13 | 0x00 | 0x00 |
14 | 0x00 | 0x00 |
15 | 0x00 | 0x00 |
16 | 0x00 | 0x00 |
17 | 0x00 | 0x00 |
18 | 0x00 | 0x00 |
19 | 0x00 | 0x00 |
20 | 0x00 | 0x00 |
21 | 0x00 | 0x00 |
22 | 0x00 | 0x00 |
23 | 0x00 | 0x00 |
24 | 0x00 | 0x00 |
25 | 0x00 | 0x00 |
26 | 0x00 | 0x00 |
27 | 0x00 | 0x00 |
28 | 0x00 | 0x00 |
29 | 0x00 | 0x00 |
30 | 0x79 | 0x79 |
31 | 0x00 | 0x00 |
32 | 0x00 | 0x00 |
33 | 0x00 | 0x00 |
34 | 0x00 | 0x00 |
35 | 0x00 | 0x00 |
36 | 0x00 | 0x00 |
37 | 0x00 | 0x00 |
38 | 0x00 | 0x00 |
39 | 0x00 | 0x00 |
40 | 0x00 | 0x00 |
41 | 0x00 | 0x00 |
42 | 0x00 | 0x00 |
43 | 0x00 | 0x00 |
44 | 0x00 | 0x00 |
45 | 0x00 | 0x00 |
46 | 0x00 | 0x00 |
47 | 0x00 | 0x00 |
48 | 0x00 | 0x00 |
49 | 0x00 | 0x00 |
50 | 0x02 | 0x00 |
51 | 0x00 | 0x00 |
52 | 0x00 | 0x00 |
53 | 0x00 | 0x00 |
54 | 0x04 | 0x00 |
55 | 0x00 | 0x00 |
56 | 0x12 | 0x00 |
57 | 0x21 | 0x00 |
58 | 0xB9 | 0x00 |
59 | 0x40 | 0x00 |
60 | 0x00 | 0x00 |
61 | 0x00 | 0x00 |
62 | 0x00 | 0x00 |
63 | 0x00 | 0x00 |
64 | 0x00 | 0x00 |
65 | 0x00 | 0x00 |
66 | 0x00 | 0x00 |
67 | 0x56 | 0x00 |
68 | 0xC5 | 0x00 |
69 | 0x03 | 0x00 |