This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 UART register settings to use parity and 2 stop bits

Other Parts Discussed in Thread: CC2540

Hi all,

I'm trying to connect do a device with a serial output of 4800 bps, 7 data bits, even parity, and 2 stop bits.  I'm using DMA, and since 4800 baud is not one of the pre-configured options, I've had to modify _hal_uart_dma.c to work with these settings.

I've been able to get 4800 bps, 8 data bits, 1 stop, and no parity working just fine, however when I configure the UxUCR register to work with the above settings the received data isn't correct - right now it looks like a '1' bit is always being set as the MSB (ie instead of receiving 0x61, 0xE1 is received).  The register setting I used is below:

UxUCR = UCR_PARITY | UCR_D9 | UCR_SPB | UCR_BIT9 | UCR_STOP;

Correct me if my interpretation of the data sheet for these register settings is wrong, but I've tried a few different combinations and none of them have worked.

Any ideas?

Thanks in advance,

Steve

  • The CC2540 only supports 8 or 9 payload bits, so presumably when set to 9bits / parity enabled / 2 stop bits as above, the parity bit sent by the transmitter is read in as the MSB and the first stop bit as the received parity bit.

    Your comment "I've been able to get 4800 bps, 8 data bits, 1 stop, and no parity working just fine" is unclear. Is this the cc2540 setting only or did you change the transmitter to 8 bit? 

    I would think the best cc2540 config for 4800-7-Y-2 serial would be 8 data bits, no parity, 2 stop bits. Further processing can then be done on the received data byte most significant bit to check parity.

  • Thanks for the reply.

    My comment on getting 4800-8-N-1 to work referred to using hyperterminal with those settings to communicate with the 2540 at those settings, indicating that the baud rate worked fine and that all problems came with decoding correctly.  I will give your suggestion of manually checking the MSB a go. 

    Thanks again.