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.

CC2541 UART - receive

Other Parts Discussed in Thread: CC2541

I'm trying to use the CC2541 UART to do simple polling communication.

Transmit is doing fine.   I can see (on a logic analyzer)  the data exit as expected (9600 baud, 8 data bits, no parity, 1 stop bit).

I can also see (on a logic analyzer) the response coming back, but I never see the U1CSR.RXBYTE bit go active.

I have set the appropriate "peripheral use bits":

P0SEL= PORT_USE_PERIF_BIT5 | PORT_USE_PERIF_BIT4;

I have set the appropriate "direction bits":

P0DIR= PORT_DIR_OUT_BIT4;

I have set the receive enable:

U1CSR = U1CSR | U1_READ_ENABLE;

where U1_READ_ENABLE is 0x40

I periodically check the UART (about once per millisecond) by:

#define HAL_UART1_BYTE_AVAILABLE(st)      \

{                                                                                     \

  if((U1CSR & U1_RXBYTE) == U1_RXBYTE) {  \

    st = 1;                                                                       \

  } else {                                                                       \

    st = 0;                                                                      \

  }                                                                                 \

}

The compiler is smart enough to just check U1CSR.RXBYTE...

But I never see a byte received...     

What did I forget to do?

Thanks!!

  • Hello. You do not need to write your down driver as there are drivers included with the stack. A good example of using the UART driver (for the 1.4.0 stack) is the serial-to-BLE bridge:

    http://processors.wiki.ti.com/index.php/SerialBLEbridge

  • Hi Tim,

    Thanks for your response.    When using my "polling driver", I only seemed to see one character of the sequence I expected.  I have attached a logic analyzer trace showing the TX and RX signals.   USART1 is set to 8 data bits, No parity, 1 stop bit, Low start bit, and High stop bit.    You can clearly see the "C6" byte go out, which causes the module I am communicating with to respond with an 8 byte sequence (this is the sequence I expect.)     I only ever receive the 0x73 character.     I thought perhaps, even though I was polling at a 1 millisecond rate, I may have missed the preceding characters, so I implemented a simple interrupt driven routine to catch the characters and put them in a buffer.    I set a breakpoint at the interrupt service routine where the character is extracted from the UART.    Again, when the breakpoint is hit, the UART provides the 0x73.

    I also turned off POWER_SAVING, thinking that perhaps the CC2541 might be sleeping when the first characters came in, but this had no effect.   Further, this is very repeatable, so even if it was sleeping at some point, I wouldn't expect it to be sleeping every time I have run this.

    I saw a thread discussing the UART in the CC2541 and issues with the stop bits...    Is the UART not recognizing the earlier characters because they only have 1 stop bit?

    Any idea what might be happening?

    By the way, were you a student at Villanova?

    Thanks,

  • Yes, in fact I was a student at Villanova :) I think I may have had as a professor you for a microprocessor design class?

    Regarding your UART problem here... I'm not able to dig into register-level debugging right now but everything looks good conceptually. I'm not sure which threads you are referring to but there is certainly no bug in the CC2541 UART.

    It sounds like you're trying to reinvent the wheel here...is there any reason you don't want to use the UART drivers provided with the SDK?
  • I got it to work... Still not sure why it wasn't working before. I am "reinventing the wheel" a bit. I looked over the driver example and found it to be much more complicated than I needed. My application also had some strange requirements... Thanks! Glad to see you are with TI!