To have
According to Microsoft documentation, to make ReadFile return after first byte received you shouold
" sets ReadIntervalTimeout and ReadTotalTimeoutMultiplier to MAXDWORD and sets ReadTotalTimeoutConstant to a value greater than zero and less than MAXDWORD"
But in you app you have only ReadIntervalTimeout set to MAXDWORD. All other timeouts are zero
COMMTIMEOUTS newTimeouts = { MAXDWORD,0,0,0,0 };
if (!SetCommTimeouts(*serialHandle, &newTimeouts))
Hi alex,
Thank your help.
I tried with the following instruction COMMTIMEOUTS newTimeouts = { MAXDWORD,MAXDWORD,1,0,0 };
unfortunatly, result is the same, I still have to 2ms delay on read.
We performed more test on this issue and I want to inform you about where we are.
We executed exactly the same appliaction on our legacy hardware, IMX27 and wince6 (home made BSP), delay mesured is arround 470µs (see attached snapshot).
Hi, we made some test with different thread priority. We got the same result for all configuration. Thread priority changes does not reduce the latensy
I just now tested with your code on Col iMX6S with CE7 and found the same latency (2ms) as observed by you on WCE2013.
For Col iMX6, we don’t have CE6 image available so , the CE6 you are talking about is your own built image that you tested on some different hardware (IMX27) ?
Good to see you are able to reproduce the issue, jcy mentioned a test we made on wince6/IMX27, he was talking about a legacy product we have where BSP was made internally.
Related to Alex.tx suggestion, we made tests with different priorities (from 153 to 255) unfortunately results were the same each time, we had 2ms delay on read.
Referring to the iMX6 reference manual for UART Control registers.
For UART2, Modifying the following register helped in reducing the response time.
UART2_UFCR ( Absolute Address : 0x021e8090 ).
RXTL (5-0) <— Set this to 1
You can modify the register value using our RegAccessTool or can use MapMem library to modify the register value in your source code.
eg.
DWORD UART2_UFCR; // address : 0x021e8090
DWORD *reg;
reg = (DWORD *)Map_MapMemory((DWORD)0x021e8090, 4);
UART2_UFCR = *reg;
// read the register value
wprintf(L"UART2_UFCR =\r\n\t0x%08X\r\n", Map_MemoryRead(reg,32)); // It came out to be 0x000022C8
//write to the register (RXTL = 0x01)
Map_MemoryWrite(reg, (DWORD)0x000022C1, 32);
// rest is your code for rx/tx
The following output I got after making the above mentioned changes. Its around 0.1ms