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

Please post bugs and enhancements for the STM core here
User avatar
Rick Kimball
Posts: 1011
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

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

Post by Rick Kimball » Mon Aug 07, 2017 7:09 pm

I noticed that STM32vl-discovery board has now been added. I gave it a spin, Serial1.print() seems fine and spews characters. However trying to use the Serial.availble() never seems to receive any characters. I put a scope probe on PA10 and the idle voltage is ~400mA. If I type characters into the terminal program I can see data arriving. However, the voltage is way too low.

If I use the same usb dongle (a cp2102) on a Nucleo-F030R8 Board on D2/D8 it shows proper signal levels and works properly echoing characters.

Have anyone else had success using Hardware Serial1 with the STM32vl-discovery board?

Here is the code I used:

Code: Select all

void setup() {
  Serial1.begin(9600);
  Serial1.println("Echo type some stuff");
}

void loop() {
  if ( Serial1.available() ) {
    int c = Serial1.read();
    Serial1.write(c);
  }
}
-rick

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

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Tue Aug 08, 2017 6:36 am

Hi Rick,
As Said I do not have a STM32VL disco.
I've just review the code and Serial definition seems correct (pinname, pin number, USART number, IRQ,...).
Have you try to do a loop btw Rx and Tx?

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by Pito » Tue Aug 08, 2017 6:49 am

As the VL does not have USB Serial handy, it could be the PA9/PA10 uart is Serial (not Serial1).
Pukao Hats Cleaning Services Ltd.

User avatar
Rick Kimball
Posts: 1011
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 » Tue Aug 08, 2017 6:34 pm

Pito wrote:
Tue Aug 08, 2017 6:49 am
As the VL does not have USB Serial handy, it could be the PA9/PA10 uart is Serial (not Serial1).
Yeah it is using PA9/PA10. I commented above that the output works fine. It is only the receive side that is not working. It isn't ending up in the IRQ nor is the signal level correct.

To test and see if I can use Stm32CubeMx / HAL with this stm32vl board I took one of the STM32CUBE example projects for the stm32vl-discovery board and got it to compile with Eclipse. Sadly, they don't provide either a gcc makefile project or a sws4stm32 project for any of the stm32vl examples. I just slogged through it and got the UART_HyperTerminal_DMA demo application to compile and load. And yes it does work fine. It sends and receives properly and the signal levels on the pins are what I would expect.

I'm guessing the stm32vl-discovery board variant in the stm32 core is the source of the problem. This I deduced after trying a newly received NUCLEO-F103RB board which works fine with the same usb dongle as I used with the stm32vl-discovery. That uses the same F1 core code ( uart.c / HardwareSerial.cpp ) stuff. I was mainly putting this issue out there for the ST guys to notice.
-rick

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

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Wed Aug 09, 2017 8:29 pm

I think issue comes fom the HAL for F1. I will release soon an update of the F1 HAL with Uart Updated.
That's why it probably works with the cubemx.

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

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Thu Aug 10, 2017 3:05 pm

Update of the F1 are available in this PR:
https://github.com/stm32duino/Arduino_C ... 32/pull/78

User avatar
Rick Kimball
Posts: 1011
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 11, 2017 7:55 pm

fpiSTM wrote:
Wed Aug 09, 2017 8:29 pm
I think issue comes fom the HAL for F1. I will release soon an update of the F1 HAL with Uart Updated.
That's why it probably works with the cubemx.
I tried your latest check-in and it didn't change anything for the better. The STM32F100RB VL-board still is broken with regard to Serial input.
-rick

fpiSTM
Posts: 191
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 11, 2017 7:58 pm

:cry:
Ok. Thanks forthe test. I will try to get a vldisco to debug this issue. Maybe a specific part for F100 in the HAL.

User avatar
Rick Kimball
Posts: 1011
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 » Thu Aug 17, 2017 7:33 pm

OK I've spent a bunch of time looking at this trying to figure out why receive doesn't work for the stm32vl-discovery.

I've compared the NUCELO_F103RB to the DISCO_F100RB variant directories. I focused on just trying to get PA2/PA3 working.
I noticed that the F103 has the PA2/PA3 commented out of all tables except the uart ones so I changed the F100 to do the same thing. It didn't fix anything, no change.

I spent in inordinate amount of time in debug, checking to see that the USART2_IRQHandler is working. It always works on
receive for the F103 but doesn't ever work for the F100. Both chips trigger the USART2_IRQHandler when a character is transmitted.
I'm at a loss because I don't know the HAL_UART code very well. My one comment would be why are there so many state variables associated with the state of the device instead of just using the USART hardware registers to decide what is going on.

The code for the uart.c seems to be the same for F100 and the F103. I'm not sure what else to look at.

The code creates and appropriate USART IRQ handler. The code does trigger the IRQ handler at least for transmit. The HAL code is overly complex and hides what is going on to the point that I can't debug it.

As another data point the BluePill in the F1_Merge_Other branch exhibits the same problem. So I don't think it is specifically a F100 issue.
Also, I can use the same VL-Discovery Board with the stm32duino/libmaple core and the same .ino file and it works fine.

@fpiSTM Are you making any progress on this? I'm hopeful if you figure this out you might also be able to provide the same fix for the BluePill.
-rick

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

Re: STM32VL-Discovery Serial1 recv doesn't work

Post by fpiSTM » Thu Aug 17, 2017 8:10 pm

Currently not Rick :oops:
I'm trying to get a vldisco. But as you said there is the same issue on BP. I will focus on it.
Thanks for your time to try debugging this issue.
Keep in touch

Post Reply