cancel
Showing results for 
Search instead for 
Did you mean: 

"Listening" the data received by RX pin on STM32L073RZ

CAben.1
Associate II

Dear ST Community,

I am new to STM32 and I am currently trying to develop a remote control with SMT32L073RZ and Thyone I (Nordic-Based) RF Proprietary module which acts as transreceiver. the communication is through UART.

Setup1:

Transmitter: Thyone I RF Module hooked to Nucleo L073RZ (UART1) Thyone I USB Dongle with the use of a Terminal Program

Receiver: Thyone I USB Dongle with the use of a Terminal Program.

Here i was able to transmit and visualise data on the Terminal. No problems here!!!

Setup2:

Transmitter: Thyone I USB Dongle with the use of a Terminal Program

Receiver: Thyone I RF Module hooked to Nucleo L073RZ (UART1)

In this setup, I know for a fact that the RF module receives the transmited data from the Dongle because of the blinking RX LED, but unfortunately, i can use/access this data.

Question: How can I listen to my received data on the RX pin and save it in an array or string? For any further questions please, do not hesitate to ask. Thank you

3 REPLIES 3
KnarfB
Principal III

Hi,

its not clear to me how you connected everything, i.e. in Setup1 if you're using an USB dongle, what did the Nucleo board then do (HW + SW)?

Just for testing, you can write a busy loop for the Nucleo board copying all chars from one UART to another connected to the USB VCP to the PC. So the Nucleo board acts as a serial-USB dongle on steroids. This is easiest done at register level:

  while (1)
  {
    if( USART1->ISR & USART_ISR_RXNE ) { // UART1 has a char
      char c = USART1->RDR & 0xFF;
      while( (USART2->ISR & USART_ISR_TXE) == 0 );
        USART2->TDR = c; // copy it to UART2
    }
    if( USART2->ISR & USART_ISR_RXNE ) { // UART2 has a char
      char c = USART2->RDR & 0xFF;
      while( (USART1->ISR & USART_ISR_TXE) == 0 );
        USART1->TDR = c; // copy it to UART1
    }
  }

All UARTS need proper initialization, HAL generated code is fine for that.

For production code, you later probably want to use Interrupt or DMA based receiving and processing. Here I recommend Tilen Majerles code: https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

hth

KnarfB

With the correct pin and uart configuration the USART1_RX should be able to listen/snoop on other traffic using the same CMOS levels, common ground, etc.

You'd use standard UART Receive code, you could get an interrupt for each byte received, or you could spin in a main() loop polling, etc.

UART's on STM32 work materially like UARTs on other MCUs

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
CAben.1
Associate II

Thank you @KnarfB​  and @Community member​ for your answers. To give you a little more detail and insights as to what i want to do, i will attach the code I am trying out at the moment. (relatively short).

Considering setup 2 above: I use the dongle connected to my PC, and with the use of a Terminal Program to send for example a "Hello" to my Radio module which is connected to UART1 of my STM32L073RZ, and i get confirmation of receipt from my Radio Module as it blinks it LED.

i tried to implement an RX interrupt in order to receive the data and either print it on either a serial monitor or display it on another Terminal Program (HTerm), unfortunately to no avail.

I know for a fact that my UART is well set up, because i could use this button presses to send my data from my (RF Module + STM32) to the dongle and it was displayed opn the terminal program.

I would be glad if can check my code and tell me what i doing wrong and for any further questions please, do not hesitate to ask. Thank you.