7 years ago.

Nucleo L432KC - Serial attach work around?

So it seems the Serial Attach function doesn't work on serial port 2 of the L432KC or the F303K8. For the F303K8, I can roll back to MBED version 121, and things work fine, but the L432KC wasn't supported until MBED version 122, so I don't have the option to roll back. Even when manually checking for serial.readable(), I receive nothing. Is there a work around to get Serial 2 Rx functioning on the L432KC? I don't want to have to order a reprint of this board layout.

2 Answers

7 years ago.

Try mbed version 124. See here:

https://github.com/ARMmbed/mbed-os/issues/2670

I'll give 124 a shot tonight. Thanks!

posted by Andrew Wakestrap 18 Apr 2017

Sad to report this didn't work. Rx still not working on USART2.

posted by Andrew Wakestrap 20 Apr 2017
7 years ago.

I was able to resolve my problem with the Serial attach method for USART1 on the the Nucleo L432KC by explicitly disabling the USART prior to calling the attach function, and then re-enabling the USART after the callback function is attached. The code for USART1 on the Nucleo L432KC is below. I have not tried it with USART2.

//  disable USART1
//  USART1 base address is defined in "stm32l432xx.h" 

(USART1)->CR1 &=  ~USART_CR1_UE; 

//  attach the callback function                           

pc.attach(&rx_callback,Serial::RxIrq);

//  re-enable USART1

(USART1)->CR1 |=  USART_CR1_UE;

Right now my USART1 is working fine but I'll give this code a try tonight using USART2 and see if I can get it working. I'll update later. Cheers!

posted by Andrew Wakestrap 18 Apr 2017

Sad to report this also didn't work. Thanks though!

posted by Andrew Wakestrap 20 Apr 2017

Your initial questions says, "I can roll back to MBED version 121, and things work fine". Does this mean that your code for USART2 works as expected using v121 but not later versions of the MBED code? If not, you may be having a conflict with the board's VCP function, which uses USART2 by default (see Section 6.9 of UM1956). Also, the MBED library defines USART2 as the STDIO_UART, so there may be naming conflicts there if you are using SDIO functions.

posted by J Roth 20 Apr 2017