6 years, 11 months ago.

Nucleo-L476RG - Serial gets never return

Hello,

I have a LoRawan module (mdot) and a Nucleo-L476RG board. I wanted to send command to the module through uart. The module receive AT command but when I send a simple command as "AT&F\r\n", I see with the oscilloscope that the module return the correct value but the gets function never return... If someone know what can be the problem, it would be very helpful.

Here is my code:

main.cpp

Serial pc(USBRX, USBTX);
Serial lora(A4, A5);

int main()
{      
    char buffer[100] = { 0 };

    lora.baud(115200);
    pc.printf("wait 4s\n");
    wait_ms(4000); // Let the LoRa module boot

    lora.printf("AT&F\r\n"); //Send AT command
    lora.gets(buffer, 100);   // <- Get the response. The call never end...
    
    pc.printf(buffer);
}

Note: I had to modify this line (mbed-os/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476XG/TARGET_NUCLEO_L476RG/system_stm32l4xx.c):

system_stm32l4xx.c

  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;           /* 80 MHz *

to this:

system_stm32l4xx.c

  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;           /* 20 MHz *

1 Answer

6 years, 11 months ago.

Perhaps your clock change is impacting the UART baud rates ? Test to confirm that after your clock change that your UART is indeed framing @ 115200 by applying any USB to UART convertor (NOT RS232 based but 3v3 CMOS levels) and mate the TX pin on your mbed to the RX pin of your external USB to UART convertor. Then send "0123456" or any string of your choice and be sure that Teraterm terminal configured to 115200 is able to see the same sent traffic. If not, then you are shooting blanks as the Lora module needs to be at the proper baud rate. The scope should also offer the bit widths for your baud rate - are they correct for 115200 bps ? 1/115200 should be the bit width on your scope. Alternatively, dial up 9600 bps on mbed and then check the bit width again and it should be 1/9600 if the UART clock is correct else not framing correctly for the Lora module. That is, if you can frame 9600 bps correctly then 115200 bps should also be correct. Start with this review.