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:-
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.