I’m developing an RS485 (38K4 baud) to Ethernet system that must respond with 5 byte acknowledge messages on the '485, as well as sending small amounts of data on the Ethernet side.
The device has to answer on the '485 ideally in <5mS. I tried a serial/net module made by Tibbo technology which has very poor latency. So the question is: Does the Connect ME have good enough timing to operate as an RS485 device? I’m looking at “jumping ship” to use it because the Tibbo module has given all sorts of timing headaches!!
Perhaps. Unfortunately, the system (ME w/ Net+OS, at least) does not support task-aware serial, so there’s no way to (for example) block a thread on receiving 5 characters, then send something back quickly. So you end up polling, sleeping, polling etc. With the standard tick rate (100 Hz), it could therefore be 10ms before you realize that your serial data has been received. Perhaps if you crank the clock up to 1kHz, however, that could potentially get you under 5ms for everything, especially if you serial polling task were a high priority.
If the polling task could be set to 1mS or even 2mS it should work. Also if the code that looked at the incoming data could recognise the last 5 bytes (or more) within 1mS, and initiate a “serial send” task, that would be fine. We can leave a gap of several mS to allow a response, but over 5mS is getting silly.
It seems strange that serial data reception is not interrupt/task driven. The micro originating+receiving data is an 8031 at 24MHz, i.e. over 10x slower than a 55MHz ARM… welcome to the world of RTOS I guess?
Actually several issues here. I can’t remember whether the physical data transfer from receive FIFO to memory uses DMA or interrupts, but normally its done in bursts when there are more than a certain number of characters (8?) in the receive FIFO. A timer forces an interrupt/FIFO read if no characters are received for a short time. So thats one source of delay.
Then, as dhansen said, you have to wait for the RTOS task swapping - don’t know whether trying to read serial data using blocking I/O would help.
The serial driver in the BSP is fairly full-featured (= bloated for simple applications) - several times I’ve been tempted to strip it down to do exactly what I want, or clone it in my application to bypass the BSP for serial.