[SOLVED] STM32VL-Discovery Serial1 recv doesn't work

Please post bugs and enhancements for the STM core here
fpiSTM
Posts: 226
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Fri Aug 18, 2017 8:55 am

Rick, Could you test by adding in uart.c, function: void uart_init(serial_t *obj) in the //Configure uart part

Code: Select all

  huart->gState = HAL_UART_STATE_RESET;
before the call of:

Code: Select all

  if(HAL_UART_Init(huart) != HAL_OK) {
    return;
  }

User avatar
Rick Kimball
Posts: 1040
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by Rick Kimball » Fri Aug 18, 2017 11:37 am

I tried that ... no difference.

As another data point, I went into the debugger and before the line I added was executed it was already set to HAL_UART_STATE_RESET

Code: Select all

Breakpoint 3, uart_init (obj=obj@entry=0x20000218 <Serial+148>) at /home/kimballr/Arduino/hardware/st/stm32/cores/arduino/stm32/uart.c:248
248	  huart->Init.OverSampling = UART_OVERSAMPLING_16;
(gdb) l
243	  huart->Init.WordLength   = obj->databits;
244	  huart->Init.StopBits     = obj->stopbits;
245	  huart->Init.Parity       = obj->parity;
246	  huart->Init.Mode         = UART_MODE_TX_RX;
247	  huart->Init.HwFlowCtl    = UART_HWCONTROL_NONE;
248	  huart->Init.OverSampling = UART_OVERSAMPLING_16;
249	  // huart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
250	  huart->gState = HAL_UART_STATE_RESET;
251	
252	  if(HAL_UART_Init(huart) != HAL_OK) {
(gdb) p/x huart->gState
$9 = 0x0
(gdb) p huart->gState
$10 = HAL_UART_STATE_RESET
(gdb) n
250	  huart->gState = HAL_UART_STATE_RESET;
(gdb) n
252	  if(HAL_UART_Init(huart) != HAL_OK) {
(gdb) p huart->gState
$11 = HAL_UART_STATE_RESET
(gdb) p/x huart->gState
$12 = 0x0
(gdb) p *huart 
$13 = {Instance = 0x40004400, Init = {BaudRate = 9600, WordLength = 0, StopBits = 0, Parity = 0, Mode = 12, HwFlowCtl = 0, OverSampling = 0}, pTxBuffPtr = 0x0, TxXferSize = 0, TxXferCount = 0, pRxBuffPtr = 0x0, RxXferSize = 0, RxXferCount = 0, hdmatx = 0x0, hdmarx = 0x0, Lock = HAL_UNLOCKED, gState = HAL_UART_STATE_RESET, RxState = HAL_UART_STATE_RESET, ErrorCode = 0}
-rick

fpiSTM
Posts: 226
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Fri Aug 18, 2017 12:13 pm

I think it was the case as compiler init all to 0 (=HAL_UART_STATE_RESET)
Thanks for the test. I will try with the BP, I've rebase the PR so I could test.

fpiSTM
Posts: 226
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Sun Aug 20, 2017 9:31 am

Issue come from GPIO config for Uart rx pin.
For F1 it should be configured as

Code: Select all

STM_MODE_INPUT
instead of

Code: Select all

STM_MODE_AF_PP
Due to specific AF way of working.
Mark the topic as Solved.

User avatar
Rick Kimball
Posts: 1040
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: [SOLVED] STM32VL-Discovery Serial1 recv doesn't work

Post by Rick Kimball » Sun Aug 20, 2017 2:40 pm

Just to be clear, this problem isn't fixed in the current master just in your private repo/branch, yes?

https://github.com/fpistm/Arduino_Core_ ... mits/F1_AF
-rick

fpiSTM
Posts: 226
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: [SOLVED] STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Sun Aug 20, 2017 3:06 pm

Yes,Rick, I'm waiting fprwi6labs comment if any before merge it ;)

Post Reply