cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746ZG UART4 to UART7

bongumsa12
Associate III

Lately, I have been trying to program the UART module of the STM32F746ZG. The program didn't work at all. I tried programming the USART module as a UART. The program worked. I then noticed that the reference manual does not talk much or barely anything about UART4 to UART7. They only focus on the USART modules. This got me thinking, "Is the UART Module on the STM32F746ZG based on a different manufacturer architecture". If so, which one? Because the ARM cortex M7 generic user guide doesn't have anything on UART. 

9 REPLIES 9

UART in STM32 is identical to USART, just simply has the synchronous logic omitted.

If your program did not work, there was an error in it (that includes any library you were using).

JW

TDK
Guru

The U(S)ART isn't an M7 feature, it's an STM32 peripheral and would be covered in the reference manual. It is ST's creation.

If you feel a post has answered your question, please click "Accept as Solution".
bongumsa12
Associate III

I tried programming USART1 and USART2 with the same program. But with some peripheral changes. USART2 works, but USART1 doesn't. Which is something I find strange.

They should program nearly identically. They are on different APB, and will need clocks enabling.

It's a lot easier to understand "not working" if you show the code you're attempting to use..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
#include <stm32f0xx.h>

// PB6 - Tx, PB7 - Rx

int main(void)
{
RCC -> APB2ENR |= (1UL << 14); // enable USART1 clk
RCC -> AHBENR |= (1UL << 18); // enable port A clk
RCC -> CFGR3 |= (1U << 0);
RCC -> CFGR3 &=~ (1U << 0);

GPIOB -> MODER |= (2UL << 12); // set mode to AF
GPIOB -> MODER |= (2UL << 14);

GPIOB -> AFR[0] = 0;

USART1 -> CR1 &=~ (1U << 28); // word length
USART1 -> CR1 &=~ (1U << 12);

USART1 -> BRR = 833;
 
USART1 -> CR2 &=~ (2U << 12); // 1 stop bit

USART1 -> CR1 |= (1U << 0); // UE bit
USART1 -> CR1 |= (1U << 3);

while(1)
{
while(!((USART1 -> ISR) & (1U << 7)));
USART1 -> TDR = 'h';
while(!((USART1 -> ISR) & (1U << 6)));
}

return 0;
}

This is a simple program I wrote for USART1 on the STM32F042K6. I couldn't get it to work for USART1. But it does work for USART2. The same applies to the STM32F746ZG.

 S

When in doubts, start with reading out registers of related peripherals (here, USART and GPIO) and checking whether they are set as intended.

Also, make sure the pins have the connectivity you assume they have. A simple test is to set them as GPIO output, toggle and measure.

JW

Code for the F042 surely isn't going to work on the F746. Show the UART4 and UART7 code, or the USART1 vs USART2 code that work / don't work. Lets stick with one architecture and one problem.

The AFR setting will almost certainly be different, and best not done with blind/blanket writes.

The presented does or does not work? Show the USART2 code that works as the counter-point

This does what? USART1SW = 0 ? Baud = 57600 ?

RCC -> CFGR3 |= (1U << 0);
RCC -> CFGR3 &=~ (1U << 0);
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..