cancel
Showing results for 
Search instead for 
Did you mean: 

Using USART1 Rx on STM32H750B-DK

nsingh
Associate II

Hi , 

I am trying to use the USART1 to talk to another device which is runnig UART and sending and receiving data. 

I am able to see that the data from USART1 Tx (STM32) is received on the other device but the data being sent from the other device is not updating my rxbuffer. In other words,my STM32 USART1 Rx is not working . 

I did a local loopback but I do not see it functioning either . 

I have uploaded my main.c here with the code I am running and you will see that the rx is based on the ISR and is using the callback function to print the data. 

I would need some guidance to understand if I am missing some config that this peripheral needs for Rx. 

Also , GPIO pins used are PB7 and PB14 . PB14 is working since I can see the data received on the other device (sent by STM32) but not PB7 which is the Rx here. 

 

I have uploaded few files that may be of interest here to review . 

 

 

3 REPLIES 3

Isn't the USART1 supposed to be initialized in the MSP file

Why do you have this broken stuff in the GPIO code in main? It commented out, but no comment/notes as to why

/*Configure GPIO pins for USART1 , PD7 and PD14*/
/* GPIO_InitStruct.Pin = GPIO_PIN_7 ;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); */
/* USER CODE END MX_GPIO_Init_2 */

How are you escaping the signals?

The Arduino shield escapes USART1 via PB6 / PB7

The STMOD only exposes PB14 (USART1_TX AF4)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nsingh
Associate II

Thanks for the response, 

 

When I started writing the code I initalized the GPIO within the MX_GPIO_Init() but then realized that it was already present in the stm32h7xx_hal_msp.c . I agree now I should have commented around those lines to describe why they were there. 

On the STM32H750B-DK , the Tx is on PB14 and the Rx is on PB7 which is present on ARD_D0 CN6. I use thi s pin to connect to my Tx. 

So , hardware wise the connections seem good to me. 

I also modified the baud rates , and the tx from stm32 still works, but not the Rx. 

 

nsingh
Associate II

I went a little further to look at the registers and found that the USART1_ISR IDLE=1 , I then checked my GPIO config in the hal_msp.c and found that PB7 and PB14 were configured with different alternate functions. 

So , now they look something like this : 

 

/**USART1 GPIO Configuration

PB7 ------> USART1_RX

PB14 ------> USART1_TX

*/

GPIO_InitStruct.Pin = GPIO_PIN_7;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF4_USART1;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = GPIO_PIN_14;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF4_USART1;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

Now, USART1_ISR.IDLE=1=0 that means the Rx sees activity but it still has 0 in USART1_RDR=0.

I took a dump of USART1 registers , hopefully to get some help here.

 

STM32H750/USART1/CR1:0x2d
STM32H750/USART1/CR1/RXFFIE:0x0
STM32H750/USART1/CR1/TXFEIE:0x0
STM32H750/USART1/CR1/FIFOEN:0x0
STM32H750/USART1/CR1/M1:0x0
STM32H750/USART1/CR1/EOBIE:0x0
STM32H750/USART1/CR1/RTOIE:0x0
STM32H750/USART1/CR1/DEAT4:0x0
STM32H750/USART1/CR1/DEAT3:0x0
STM32H750/USART1/CR1/DEAT2:0x0
STM32H750/USART1/CR1/DEAT1:0x0
STM32H750/USART1/CR1/DEAT0:0x0
STM32H750/USART1/CR1/DEDT4:0x0
STM32H750/USART1/CR1/DEDT3:0x0
STM32H750/USART1/CR1/DEDT2:0x0
STM32H750/USART1/CR1/DEDT1:0x0
STM32H750/USART1/CR1/DEDT0:0x0
STM32H750/USART1/CR1/OVER8:0x0
STM32H750/USART1/CR1/CMIE:0x0
STM32H750/USART1/CR1/MME:0x0
STM32H750/USART1/CR1/M0:0x0
STM32H750/USART1/CR1/WAKE:0x0
STM32H750/USART1/CR1/PCE:0x0
STM32H750/USART1/CR1/PS:0x0
STM32H750/USART1/CR1/PEIE:0x0
STM32H750/USART1/CR1/TXEIE:0x0
STM32H750/USART1/CR1/TCIE:0x0
STM32H750/USART1/CR1/RXNEIE:0x1
STM32H750/USART1/CR1/IDLEIE:0x0
STM32H750/USART1/CR1/TE:0x1
STM32H750/USART1/CR1/RE:0x1
STM32H750/USART1/CR1/UESM:0x0
STM32H750/USART1/CR1/UE:0x1
STM32H750/USART1/CR2:0x0
STM32H750/USART1/CR2/ADD4_7:0x0
STM32H750/USART1/CR2/ADD0_3:0x0
STM32H750/USART1/CR2/RTOEN:0x0
STM32H750/USART1/CR2/ABRMOD1:0x0
STM32H750/USART1/CR2/ABRMOD0:0x0
STM32H750/USART1/CR2/ABREN:0x0
STM32H750/USART1/CR2/MSBFIRST:0x0
STM32H750/USART1/CR2/TAINV:0x0
STM32H750/USART1/CR2/TXINV:0x0
STM32H750/USART1/CR2/RXINV:0x0
STM32H750/USART1/CR2/SWAP:0x0
STM32H750/USART1/CR2/LINEN:0x0
STM32H750/USART1/CR2/STOP:0x0
STM32H750/USART1/CR2/CLKEN:0x0
STM32H750/USART1/CR2/CPOL:0x0
STM32H750/USART1/CR2/CPHA:0x0
STM32H750/USART1/CR2/LBCL:0x0
STM32H750/USART1/CR2/LBDIE:0x0
STM32H750/USART1/CR2/LBDL:0x0
STM32H750/USART1/CR2/ADDM7:0x0
STM32H750/USART1/CR2/DIS_NSS:0x0
STM32H750/USART1/CR2/SLVEN:0x0
STM32H750/USART1/CR3:0x1
STM32H750/USART1/CR3/TXFTCFG:0x0
STM32H750/USART1/CR3/RXFTIE:0x0
STM32H750/USART1/CR3/RXFTCFG:0x0
STM32H750/USART1/CR3/TCBGTIE:0x0
STM32H750/USART1/CR3/TXFTIE:0x0
STM32H750/USART1/CR3/WUFIE:0x0
STM32H750/USART1/CR3/WUS:0x0
STM32H750/USART1/CR3/SCARCNT:0x0
STM32H750/USART1/CR3/DEP:0x0
STM32H750/USART1/CR3/DEM:0x0
STM32H750/USART1/CR3/DDRE:0x0
STM32H750/USART1/CR3/OVRDIS:0x0
STM32H750/USART1/CR3/ONEBIT:0x0
STM32H750/USART1/CR3/CTSIE:0x0
STM32H750/USART1/CR3/CTSE:0x0
STM32H750/USART1/CR3/RTSE:0x0
STM32H750/USART1/CR3/DMAT:0x0
STM32H750/USART1/CR3/DMAR:0x0
STM32H750/USART1/CR3/SCEN:0x0
STM32H750/USART1/CR3/NACK:0x0
STM32H750/USART1/CR3/HDSEL:0x0
STM32H750/USART1/CR3/IRLP:0x0
STM32H750/USART1/CR3/IREN:0x0
STM32H750/USART1/CR3/EIE:0x1
STM32H750/USART1/BRR:0x1a0b
STM32H750/USART1/BRR/BRR_4_15:0x1a0
STM32H750/USART1/BRR/BRR_0_3:0xb
STM32H750/USART1/GTPR:0x0
STM32H750/USART1/GTPR/GT:0x0
STM32H750/USART1/GTPR/PSC:0x0
STM32H750/USART1/RTOR:0x0
STM32H750/USART1/RTOR/BLEN:0x0
STM32H750/USART1/RTOR/RTO:0x0
STM32H750/USART1/RQR:null
STM32H750/USART1/RQR/TXFRQ:null
STM32H750/USART1/RQR/RXFRQ:null
STM32H750/USART1/RQR/MMRQ:null
STM32H750/USART1/RQR/SBKRQ:null
STM32H750/USART1/RQR/ABRRQ:null
STM32H750/USART1/ISR:0x6200c0
STM32H750/USART1/ISR/TXFT:0x0
STM32H750/USART1/ISR/RXFT:0x0
STM32H750/USART1/ISR/TCBGT:0x0
STM32H750/USART1/ISR/RXFF:0x0
STM32H750/USART1/ISR/TXFE:0x0
STM32H750/USART1/ISR/REACK:0x1
STM32H750/USART1/ISR/TEACK:0x1
STM32H750/USART1/ISR/WUF:0x0
STM32H750/USART1/ISR/RWU:0x0
STM32H750/USART1/ISR/SBKF:0x0
STM32H750/USART1/ISR/CMF:0x1
STM32H750/USART1/ISR/BUSY:0x0
STM32H750/USART1/ISR/ABRF:0x0
STM32H750/USART1/ISR/ABRE:0x0
STM32H750/USART1/ISR/UDR:0x0
STM32H750/USART1/ISR/EOBF:0x0
STM32H750/USART1/ISR/RTOF:0x0
STM32H750/USART1/ISR/CTS:0x0
STM32H750/USART1/ISR/CTSIF:0x0
STM32H750/USART1/ISR/LBDF:0x0
STM32H750/USART1/ISR/TXE:0x1
STM32H750/USART1/ISR/TC:0x1
STM32H750/USART1/ISR/RXNE:0x0
STM32H750/USART1/ISR/IDLE:0x0
STM32H750/USART1/ISR/ORE:0x0
STM32H750/USART1/ISR/NF:0x0
STM32H750/USART1/ISR/FE:0x0
STM32H750/USART1/ISR/PE:0x0
STM32H750/USART1/ICR:null
STM32H750/USART1/ICR/WUCF:null
STM32H750/USART1/ICR/CMCF:null
STM32H750/USART1/ICR/UDRCF:null
STM32H750/USART1/ICR/EOBCF:null
STM32H750/USART1/ICR/RTOCF:null
STM32H750/USART1/ICR/CTSCF:null
STM32H750/USART1/ICR/LBDCF:null
STM32H750/USART1/ICR/TCBGTC:null
STM32H750/USART1/ICR/TCCF:null
STM32H750/USART1/ICR/TXFECF:null
STM32H750/USART1/ICR/IDLECF:null
STM32H750/USART1/ICR/ORECF:null
STM32H750/USART1/ICR/NCF:null
STM32H750/USART1/ICR/FECF:null
STM32H750/USART1/ICR/PECF:null
STM32H750/USART1/RDR:0x0
STM32H750/USART1/RDR/RDR:0x0
STM32H750/USART1/TDR:0xa
STM32H750/USART1/TDR/TDR:0xa
STM32H750/USART1/PRESC:0x0
STM32H750/USART1/PRESC/PRESCALER:0x0