STM32 ARM UART

An area to discuss ARM specific problems and examples

Moderator: Benj

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

STM32 ARM UART

Post by PicoPuls »

What are the rules to use UART serial over USB ?

In this tutorial https://www.youtube.com/watch?v=O_cPIL2LudY it is explained
that if you use the yellow marked pin 17 1nd 18 (Image A), then Flowcode use the hardware UART with
internal buffers - but you can use any pin and Flowcode creates a software UART
STM32F469-Discovery-kit.jpg
STM32F469-Discovery-kit.jpg (185.69 KiB) Viewed 30634 times
In Image B you have STM32F469-Discovery
How can the "User USB" be used as UART
(for serial communication with PC)
where UART works with high performance with the chip hardware and the internal buffers ?

The same question applies for STM32F407VGT6. (The biggest chip supported by flowcode i think.)
UART 1 occupies PA9 & PA10
IF a UART is created in Flowcode and given PA9 & PA10
will it then automatically use the hardware resources on chip for UART1 ?
Attachments
STM32F407VGT6.jpg
STM32F407VGT6.jpg (83.33 KiB) Viewed 30634 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 ARM UART

Post by LeighM »

In Image B you have STM32F469-Discovery
How can the "User USB" be used as UART
(for serial communication with PC)
where UART works with high performance with the chip hardware and the internal buffers ?
No, we don't yet support the USB peripheral (e.g. a virtual COM port)
The same question applies for STM32F407VGT6. (The biggest chip supported by flowcode i think.)
UART 1 occupies PA9 & PA10
IF a UART is created in Flowcode and given PA9 & PA10
will it then automatically use the hardware resources on chip for UART1 ?
Yes, if you set the properties of the Flowcode UART to "Channel 1 - USART1" and set the connections to PA9 & PA10

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

That's helpful , thanks.

As USB-UART is not yet supported in STM32F469-Discovery

how hard would it be to transfer your example
http://www.matrixtsl.com/mmforums/viewt ... 65&t=18716 F469 Disco counter display.fcfx
into the STM32F407VGT6 ?

That will allow the use of 2 hardware timers ( time count & external pulse count + regular reset, each revolution )
and hardware UART

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi PicoPuls

Thank you for your infos.

If I understand you rigth. I can connect on the USB out (from the 32F469i) to this small board on the jumper-side and use the USB (from the small Board) to connect a computer? And use the UART1 from the 32F469i?

http://store.digilentinc.com/pmod-usbua ... interface/
Digilent-410-212.PNG
(356.14 KiB) Downloaded 14437 times

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

LeighM wrote:
> No, we don't yet support the USB peripheral (e.g. a virtual COM port)

But flowcode UART component indicates that there are two hardware USART available and one software version.
See image.
As reply to Stefan Erni: If the USART hardware is available there should be no need to buy any further board.

Looking forward to Matrix comment on this....
Attachments
STM32F469-Discovery-kit_usart.jpg
STM32F469-Discovery-kit_usart.jpg (136.12 KiB) Viewed 30615 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 ARM UART

Post by LeighM »

OK, sorry I'm getting a bit confused as to what you are trying to do.
Yes there are UARTs supported, so you could connect the UART to a FTDI type board then via the USB to a PC, as a virtual COM port.
I thought you were wanting to go directly from the USB on the Discovery board (which is not yet supported)

As for the STM32F407VG, it would be best if you could start this yourself, based on my example and the previous notes, and see how you get on.
Then let us know when you need further help.

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

This is confusing, but based on this answer stefan.erni was right about the need for an extra board.

Regarding STM32F407VG and how to configure two counters:
This is the STM32F469-Discovery-kit configuration. Can I use the same configuration code ? Or how much is board-specific ?
Deeply grateful for a comment on this before I dare give it a try.

Code: Select all

// Configure PA7 to Alternate mode
GPIOA->MODER |= 0x8000;
// Configure PA7 to AF2
GPIOA->AFR[0] |= 0x20000000;
// Configure PA7 with pull-up
GPIOA->PUPDR |= 0x4000;
__HAL_RCC_TIM3_CLK_ENABLE();
// To configure the upcounter to count in response to a rising edge on the TI2 input
// 1. Configure channel 2 to detect rising edges on the TI2 input by writing CC2S = '01' in the TIMx_CCMR1 register.
TIM3->CCMR1 |= (1 << 8);
// 2. Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1 register
// 3. Select rising edge polarity by writing CC2P=0 and CC2NP=0 in the TIMx_CCER register.
// 4. Configure the timer in external clock mode 1 by writing SMS=111 in the TIMx_SMCR register.
TIM3->SMCR |= 7;
// 5. Select TI2 as the trigger input source by writing TS=110 in the TIMx_SMCR register.
TIM3->SMCR |= (6 << 4);
// 6. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
TIM3->CR1 |= 1;

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 ARM UART

Post by LeighM »

Yes, it should be OK for 407 too

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

I still feel confusion about using a UART serial communication over USB to a PC
From the discussion I understood that STM32F469-Discovery will nor support it without external board.


What's about STM32F072 Discovery ?
http://www.st.com/en/evaluation-tools/3 ... overy.html

It says
User USB with Mini-B connector
Can it be used as serial comm to PC ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: STM32 ARM UART

Post by Benj »

Hello,

A UART is a serial peripheral, but is not capable of USB communications.

A USB peripheral can be used to make a virtual com port (amongst other things) which is similar to a UART in terms of data but different in that it is a totally separate peripheral.

We do want ST ARM support for USB and I believe we have some working code but it's not quite been wrapped up into the USB Serial component yet. Hopefully this will come soon.

So for now you need to complete the gap between the UART peripheral and the USB communications, this gap filler is usually an IC with USB connunications and a UART e.g. an FTDI chip or the pmodUSBUart board shown above and hence the external circuitry.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: STM32 ARM UART

Post by QMESAR »

Hi All
Not trying to High jack a ARM discussion however we are waiting for PIC32 USB support since te release of FC7 with the comment USB will be soon to follow just hoping that the support for ARM USB does not jump out before PIC32 USB,then we PIC users will be very unhappy :D

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: STM32 ARM UART

Post by Benj »

While I remember I will order a load of PIC32 devices this afternoon so we have a better test platform and so we can gain more familiarity and hopefully crack USB for PIC32. :D

Edit: Done :)

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

I made a quick and dirty test this way

Just connected different STM32 boards to USB to see if PC discovers a COM port

In these cases a COM was discovered
F429 Disco
F469 Disco
F746 Disco
F767 NUCLEO

Then a flowcode UART loop was made to echo input from PC
These two cards can communicate excellent with PC without external boards

F429 Disco
F746 Disco

Also this board can be programmed with Flowcode and
https://shop.mikroe.com/development-boa ... -pro-stm32
serial-communicates excellent with PC over USB when chip STM32F407VGT6 is used.



Have a nice weekend!

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi Picopuls


Good news. Can I have the Flowcode program for the F469Disco?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: STM32 ARM UART

Post by QMESAR »

:D
I have been using the mikro-Electronika USB UART Click board in designs for a long time
PIC32 UART to FTDI USB translator on the click board works perfect.
:D
Attachments
2.JPG
2.JPG (19.36 KiB) Viewed 30557 times
1.JPG
1.JPG (24.1 KiB) Viewed 30557 times

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: STM32 ARM UART

Post by PicoPuls »

  • >Good news. Can I have the Flowcode program for the F469Disco? stefan.erni
This is the simple code to test UART
(Pls observe that it did't work for F469Disco)

but it works for

F429 Disco
F746 Disco
Attachments
469_disco_uart___NO.fcfx
(9.73 KiB) Downloaded 382 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi PicoPuls


I do not know if your circuit generally works. But there is already a problem with the configuration uart1. The Pin on the USB connector are A11, A12. This are not the pin rx/tx from uart1(I'm not sure, just in the datasheet of STM32F469CPU it's differently).
I asked allready Leigh to give Access to the pin by software. Then we can choose and try....
Datasheet_cpu.PNG
(63.96 KiB) Downloaded 14273 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: STM32 ARM UART

Post by Sean »

The USB UART, provided on most ST boards via the ST-Link chip, can be selected from Flowcode.
It seems that all Nucleo boards (32-pin, 64-pin and 144-pin versions) have connections to the USB UART by default.
Not all Discovery boards provide this feature, but the F429, F469 and F746 LCD boards do.

The required UART pins do not appear as I/O if they are not available externally, but can be selected as connections in the hardware U(S)ART component properties.

USB U(S)ART Examples:
Discovery F429 - USART1: TX = PA9; RX = PA10 (Note: SB11 and SB15 must have links added)
Discovery F469 - USART3: TX = PB10; RX = PB11
Discovery F746 - USART1: TX = PA9; RX = PB7
Nucleo 32-Pin - USART2: TX = PA2; RX = PA15
Nucleo 64-Pin - USART2: TX = PA2; RX = PA3 (Note: D0 and D1 on the Arduino connectors of these boards are open-circuit with the default jumper settings)
Nucleo 144-Pin - USART3: TX = RD8; RX = RD9

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi Sean

Your info is a big help.
I think you explain as if we can use the same USB connector as for the ST-link.
That would be very good. But can you help us a little more?
After I config the USB-Serialport,initalise to port and send a string, what do I have to do else?
I can see in my computer a com7 from the board but my terminalprogram can not receive a string .
Do I have to switch on the ST-link chip something?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: STM32 ARM UART

Post by Sean »

Hello

The ST-Link USB UART does not need to be enabled, it should be available whenever the ST-Link chip is powered.

I did have some problems (probably driver related) with one of my PCs. The COM port was visible but no data could be transferred unless the Windows (Win7) driver was uninstalled and re-installed each time it was used. The problem was solved when a full re-installation was completed.

Do you have the latest ST drivers?

I have re-checked the connections for the F469 Discovery and everything seems to be correct: USART3, TX=PB10, RX=PB11.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi Sean
I installed the latest St-usb-driver on a win7 and a win10 computer...
I can see the port but I can not receive the string.


devicemanager_infos.PNG
(11.55 KiB) Downloaded 14147 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: STM32 ARM UART

Post by Sean »

Do you get the same problem with Win7 and Win10?

Is there anything you can do to confirm that the program is running correctly?

Example:
Temporarily use USART6 on D0/D1 of the Arduino connectors and use an oscilloscope or USB-UART cable to check the signals.

To solve my original problem (the same symptoms as you are seeing), each time I wanted to use the COM port I had to:
Connect the board into the PC.
Open Device Manager and uninstalled the driver.
Disconnect the board.
Re-connect the board and wait for the COM port to re-appear.
Open the terminal program.

This usually allowed the port to work correctly. It might confirm a driver installation problem if this also works for you.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi Sean

Do You mean uart or USB Serial in FC7?
If it's USB Serial then it's not possible to change to uart6.....


I tried it with a stm32F429 Disco on 2 computer( Win7 and Win10) .On both it's not working.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: STM32 ARM UART

Post by Sean »

This should be using UARTs

I've been using the F469 Discovery as an example but the same should apply to the F429, with the following changes:
The ST-Link USB - USART is USART1, TX = PA9, RX = PA10.

Connection requires links SB11 and SB15 (on the reverse side of the board) to be fitted. The schematic indicates that they are not fitted by default but they are solder bridged on my board. It is possible that I added these links some time ago.
Alternatively, wire links from PA9 and PA10 on connector P1 can be connected to the RX and TX vias on JP4, respectively.
Note: JP4 TX and RX are labelled for their ST-Link functionality so must be connected to the opposite functions on the F429.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: STM32 ARM UART

Post by stefan.erni »

Hi Sean

ok, I can connect now to the pc and receive the string. I can use 921600 baud. it's working on win7 and win10.

The last Problem was on the propertis/Connection from the uart3, I can not see remaping TX and RX.
But when I clicked in the "triangle" and I choosed B10 and B11 it was working.
uart_remap.PNG
(30.15 KiB) Downloaded 14130 times

Post Reply