Always getting a Space instead of Mark with 9-bit UART configuration

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MiSt_296941
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

 

I have a unique 9-bit UART application.  The 9th bit is only set when the host wants me to know that byte is the start of a packet (to re-synchronize).   The problem is that when debugging the project, I don't ever see the RxStatus change when I send I byte with a Mark vs a byte with a space.  I am stopping the code in the UART_A_INT.c file just after it reads the byte from the register (status previously read and saved in a local var).

The UART configuration is set to Address Byte = None.  I can't set it to anything else because my code will no longer fit (used up too many UDBs).  I prefer not to upload project as it is very large and proprietary.  Here is a code snippet:

The following is from the UART_A_INT.c file.  This is mostly auto-generated by building the project.  I have added the last bit after the data is read from the UART data register.  I put a breakpoint after the read data register and inspect it and the status.  The data is always correct but I never see the status register change when I send a space vs a mark!   I am using a Terminal program to send the data and it allows me to configure it to send a space or mark with the character (8 bit).  I have verified with a scope that it is working.

/* Read receiver status register */
readStatus = UART_A_RXSTATUS_REG;
/* Copy the same status to readData variable for backward compatibility support
* of the user code in UART_A_RXISR_ERROR` section.
*/
readData = readStatus;

if((readStatus & (UART_A_RX_STS_BREAK |
UART_A_RX_STS_PAR_ERROR |
UART_A_RX_STS_STOP_ERROR |
UART_A_RX_STS_OVERRUN)) != 0u)
{
/* ERROR handling. */
UART_A_errorStatus |= readStatus & ( UART_A_RX_STS_BREAK |
UART_A_RX_STS_PAR_ERROR |
UART_A_RX_STS_STOP_ERROR |
UART_A_RX_STS_OVERRUN);
/* `#START UART_A_RXISR_ERROR` */

/* `#END` */

#ifdef UART_A_RXISR_ERROR_CALLBACK
UART_A_RXISR_ERROR_Callback();
#endif /* UART_A_RXISR_ERROR_CALLBACK */
}

if((readStatus & UART_A_RX_STS_FIFO_NOTEMPTY) != 0u)
{
/* Read data from the RX data register */
readData = UART_A_RXDATA_REG;

#define HW9thBitA
// Handle 9th bit set - HW system wants this to be the first byte in a packet (command).
if (readStatus & UART_A_RX_STS_MRKSPC) // Is this a Mark?
{ // If so...
UART_A_rxBufferRead = 0u; // Clear the buffer as this new byte will be the first one in a packet.
UART_A_rxBufferWrite = 0u;
UART_A_rxBufferLoopDetect = 0u;
UART_A_rxBufferOverflow = 0u;
NinethBitSetA = 1; // Set flag for Callback routine.
}

 

I found this in the component datasheet:

UART_RX_STS_MRKSPC * Status of the mark/space parity bit. This bit indicates whether a mark or
space was seen in the parity bit location of the transfer. It is only
implemented if the address mode is not set to None.

 

Does this mean that I'm hosed?  Seems dumb that we can't get at the Mark/Space bit without implementing an Address mode.

Mike.

0 Likes
2 Replies
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @MiSt_296941 ,

As per the UART component datasheet , UART_RX_STS_MRKSPC status is used to indicate the detection of an address byte as you can read about the "Address Mode" under the component parameters. Hence, UART_RX_STS_MRKSPC is implemented only when the address mode is not set to None.  And because UART_RX_STS_MRKSPC indicates the status of mark/space parity bit , I suggest you to follow this.

However,  there is an API UART_SetRxAddressMode() , which can be used to set the software controlled Addressing mode used by the RX portion of the UART. You can read about this API in detail in the component datasheet here : https://www.cypress.com/file/177171/download.  

Also, through your statement -> I am stopping the code in the UART_A_INT.c file just after it reads the byte from the register (status previously read and saved in a local var).

>> I believe you are letting us know that the code snippet which you have shared here is the only code which you have in your UART_A_INT.c file. Please help me clarify this. 

Please follow the above steps once and let us know in case of further queries.

Best Regards,

Aashita

0 Likes

It's extremely unfortunate that Cypress decided that you only want to use the 9th bit if you are addressing transmissions.  This is NOT the case for all applications.  In my case the Host I am communicating with sets the 9th bit on the first byte of a packet so you know you are starting a new packet.  My project is so large that I cannot enable Addressing mode because I run out of UDBs.

Your comment about the API UART_SetRxAddressMode() does not apply since it is only available IF you have enabled Addressing mode and as I said, I cannot.

A code snippet is just that - a portion of code - not the whole thing, so no, I only pasted a portion of the UART_A_INT.c file.

I need a way of capturing the 9th bit without enabling addressing mode which eats up too many UDBs.

Mike.

0 Likes