VF50: How to do 9-bit data-byte size UART data communication?

We need to implement a serial communication protocol with 9-bits per data byte. Each serial frame, consisting of ‘n’ number of bytes, will be transmited with 9th bit in every data byte of that serial frame set as ‘0’ or ‘1’ depending on the protocol state machine.

Standard UART serial communication parameters is used:- 8 data-bits, NoParity, 1 StopBit.

Referencing the “NXP VFxx Controller Reference Manual” we basically need to set ‘UART2_C1[M]’ bit set to 1 and then manipulate the ‘UART2_C3[T8]’ bit before doing a frame transmission.

Now our problem is we are not sure we can able to access the UARTx Register Space of the VF50 board processor. Basically we first tried only reading the UART2 Registers after Initializing the Windows CE UART driver as below:-

LPCWSTR comPortName = L"COM2:";
hPort = CreateFile(comPortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
 DCB dcb;    
GetCommState(hMstpPort, &dcb);    
dcb.BaudRate = CBR_38400;    
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT;
dcb.fParity = FALSE;
            dcb.Parity = NOPARITY;
            dcb.fOutxCtsFlow = FALSE;
            dcb.fOutxDsrFlow = FALSE;
            dcb.fDtrControl = DTR_CONTROL_DISABLE;
            dcb.fDtrControl = FALSE;
            dcb.fDsrSensitivity = FALSE;
            dcb.fOutX = FALSE;
            dcb.fInX = FALSE;
            dcb.fNull = FALSE;
            dcb.fRtsControl = RTS_CONTROL_DISABLE;
            dcb.fAbortOnError = FALSE;                
            SetCommState(hPort, &dcb);

After above we then read the UART2 Register Space using the ‘MapMem’ library as below:-

hMapMem = Map_Init();   
ASSERT(hMapMem != 0);
uartRegAddress = (byte *)Map_MapMemory((DWORD)0x40029000, 1);
UART2_BDH = *uartRegAddress;
Map_UnMapMemory(uartRegAddress);
uartRegAddress = (byte *)Map_MapMemory((DWORD)0x40029001, 1);
UART2_BDL = *uartRegAddress;
Map_UnMapMemory(uartRegAddress);
uartRegAddress = (byte *)Map_MapMemory((DWORD)0x40029002, 1);
UART2_C1 = *uartRegAddress;
......................................
......................................

Strangely we see the UART2 Register values as show in VS2008 Debugger Watchlist picture below:-

2406-com-b-uart2-regset.png

The above UART2 Register values do not make any sense at all and so we suspect we are doing something wrong in our basic test code of reading registers .

Please help us with the right way of accessing the UART2 Register Space inorder to both read and write to the required registers as explained above.

Thanks in advance.

Hi @Vijay.pst,

You can write and read the register value using the Reg Acees Tool

Hello @sahil.tx ,
We want to read/write VF50 Vybrid processor UART2 Registers programmatically in our WinCE application software. We are trying to do this using the ‘MapMem’ library as explaiend above but the issue is we are not seeing the right values in the UART2 Registers after initializing/configuring the Vybrid Serial Driver(through WinCE API calls ofcourse).

And if we try to write to ‘UART2_C1[M]’ and ‘UART2_C3[T8]’ register bits using MapMem, as explained above, we do not see the expected 9-bit data bytes(in a DSO) in any of the serial frame transmitted from VF50.

So we suspect the Vybrid Serial Driver is either not allowing access to ‘UART2_C1[M]’ and ‘UART2_C3[T8]’ registers or the ‘MapMem’ library is not able to access the UART2 Register Space prroperly.

So please guide us how to correctly read/write UART2 Registers in a ‘C’ application program using ‘MapMem’ library.

Hi @Vijay.pst,

Allow me some time to test the same at my end. In my last comment regarding RegAccessTool, this tool can be used to check whether the values are correctly written by reading the register value

Hi @sahil.tx , any update on this?
Thanks in advance for your support.

Hi,

The WinCE serial driver does not have support for 9-bit UART data transfer.

Inside the DCB structure (winbase.h)

BYTE ByteSize; /* Number of bits/byte, 4-8 */

In the reference manual, it is also mentioned that the bit UART1_C1[M] must be set when C7816[ISO_7816E] is set/enabled.

Please try with RegAccess Tool first to check whether you are able to read/write register.

Hi,

You can also try to use the parity bit as the 9th bit as described here