Other Parts Discussed in Thread: SYSCONFIG
Hi Folks,
I have assigned the native UART interfaces to two devices (115200 and 9600, both 8N1) using UART2 driver through the System Configuration tool. There are no other tasks running besides the "Serial" task. I have observed a substantial delays (+1 second) between receiving, processing, and then sending a reply over UART2 on my oscilloscope. This is pretty far from optimal and is on the verge of dysfunctional - I would like to reduce this delay by at least 800ms.
Disabling "Display_printf" for debugging via Host Display will probably improve the runtime, however, considering the delay with only one serial peripheral - well, I can't imagine two will be any better. I need to optimize the method of handling the serial peripherals.
Solutions I am considering:
- (Current) A "Serial" Task with four events (COM1_RX, COM1_TX, COM2_RX, COM2_TX) with a callback and externally accessible "serial_write" function.
- Event COMx_RX calls UART2_Read to read to a static local buffer.
- Event COMx_TX calls UART2_Write to write a static local buffer.
- "serial_write" copies a remote buffer to a static local buffer and then posts event COMx_TX depending on the port specified.
- callbackFxn_read passes the buffer pointer and length to an external function for parsing and posts event COMx_RX to re-engage the Serial RX.
- (Next Solution) A "COM1" and "COM2" task of equal priority, each demonstrating the following behavior.
- Task Loop (Serial Reading & Parsing)
- UART2_Read is called when entering task loop.
- Semaphore blocks until callbackFxn_read releases the semaphore.
- UART message is parsed locally.
- Externally accessible "serial_write" function
- "serial_write" copies a remote buffer to a static local buffer and UART2_writes the copy immediately.
- Task Loop (Serial Reading & Parsing)
Things I have considered:
- There is no system for queueing or listing messages - messages are handled as quickly as they are received or generated.
- Clocks are used to (1) generate some messages and (2) generate timeout interrupts for missing messages, time is essential.
- Three tasks (Simple Peripheral, COM1, and COM2) and will be communicating information between them - so threadsafety and latency need to be balanced.
I am looking for any and all suggestions to improve the performance here before I push forward in overall project development.
-Ken