I have a project where we are producing new "Remote" boards. We are using RS485 half duplex. The Master commands are always sent with a 1 set as the 9th bit (Mark).
The Remote UART (that I'm trying to set up) should completely ignore any data word that does not have a 1 as the 9th bit (Mark parity). This way each of the multiple remote boards will ignore any communications from the other remotes.
Only if the 9th bit is a 1 will the UART listen to the rest of the word. The rest of the word is the master command and the remote address. If the address matches the remote's address, set by DIP Switch, the remote processes the command.
Master word = 1yyyyxxxx, 1= 9th bit (Mark), yyyy =command (ie- 0100 = send buffered data), xxxx = remote address
What do I use to have the UART look for the 1 in the 9th bit (mark) and ignore anything that is not a 1?
I'm trying to understand how to control the Mark / Space parity bit before transmitting the data. If I'm reading correctly UART_CTRL_MARK, "Configures whether the parity bit during the next transaction (in Mark/Space parity mode) will be a 1 or 0."
I don't seem to understand the formatting. It looks like I should use UART_WriteControlRegister(UART_CTRL_MARK). How do I tell complete this and say whether I want the bit to be a 1 or a 0? Do I need to check the API control enable box in the UART configuration?
I'm just starting to learn a little C programming. I need basic detailed help from those smarter than I!! This is my first work with PSoC. I would welcome examples!
Right now I'm using the full duplex UART example program to try to understand how everything works. RS232 from my PC characters typed are echoing back to the PC. (115200 baud, 9 data bits, Mark / Space Parity, 1 stop bit, no flow) Notice that I'm transmitting the data twice. My intentions are to transmit one with the Mark parity set and one with Space parity set just so I can look on the scope and make sure I can see it working. I don't seem to know how to control the Mark/Space bit. Once I have this figured out, I can move on to the task above.
/* Read receiver status register */
rxStatus = UART_RXSTATUS_REG;
if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
/* ERROR handling. */
errorStatus |= rxStatus & ( UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN);
if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
/* Read data from the RX data register */
rxData = UART_RXDATA_REG;
if(errorStatus == 0u)
/* Send data backward */
UART_TXDATA_REG = rxData;
UART_TXDATA_REG = rxData;
}while((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u);