cancel
Showing results for 
Search instead for 
Did you mean: 

Problem receiving with stm32f769i-disco

jhanc.11
Senior

Hi, Haven't been here in a while, about 15yrs, ha! I dug out the subject board, STM32f769i-disco that I've used a number of times years ago. I built some code using the new cubemx, compiles fine in the new IDE. I can send data, but it just doesn't want to receive over the VCP.

According to the doc, the VCP is attached to usart1 on A9 and a10. Cubemx generates PB6 and 7 that don't work at all in tx or rx. So I changed them to a9 and a10, set the GPIO as below and I can tx without issue. But sending data to it using any of a number of codes on a PC doesn't work. it's not even getting interrupted as I am transmitting back data that should be overwritten if it had any type of reception.

 GPIO_InitTypeDef GPIO_InitStruct;

 GPIO_InitStruct.Pin     = GPIO_PIN_9;

 GPIO_InitStruct.Mode    = GPIO_MODE_AF_PP;

 GPIO_InitStruct.Pull    = GPIO_PULLUP;

 GPIO_InitStruct.Speed    = GPIO_SPEED_FREQ_HIGH;

 GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct);

 /* UART RX GPIO pin configuration */

 GPIO_InitStruct.Pin = GPIO_PIN_10;

 GPIO_InitStruct.Pull    = GPIO_PULLUP;

 GPIO_InitStruct.Alternate =GPIO_AF7_USART1;

 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Here's the init for the usart1:

 /* USER CODE END USART1_Init 1 */

 huart1.Instance = USART1;

 huart1.Init.BaudRate = 115200;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

I have usart1, GPIOA clocks enabled. What I don't get, is if the VCP is tied to usart1, shouldn't it be using PB6 and PB7 as what I think the chip sees? But the table clearly says A9 and A10 unless that is the boards connectors? Either way, I've tried both.

Simple loop in main to send any received data as well as a known message.

 while (1)

 {

  /* USER CODE END WHILE */

 HAL_UART_Receive(&huart1, rxData, 10,1000); // receive to overlay message data

 HAL_UART_Transmit(&huart1,rxData,10,1000); // send it back

 HAL_UART_Transmit(&huart1,data,10,1000); // send a known message

 HAL_Delay(100);

  /* USER CODE BEGIN 3 */

 }

I'm thinking it has something to do with the peripheral clock or I saw something about and alternative function clock and I can't find that anywhere.

Thanks,

jerry

9 REPLIES 9
jhanc.11
Senior

just to add to this. I found two little probe points for the VCP tx and rx. I see my data going out (decoded on my scope) and when I send data, I again see it coming over correctly at the correct baud. So it is getting to the board.

Try to change GPIO_PULLUP to GPIO_NOPULL. Has the cube generated GPIO_PULLUP for UART1?

Check the HSE_VALUE for the external clock.

Pretty sure the F769I-DISCO has a 25 MHz clock

stm32f7xx_hal_conf.h

..

#if !defined (HSE_VALUE)

 #define HSE_VALUE  25000000U /*!< Value of the External oscillator in Hz */

#endif /* HSE_VALUE */

Check also how the PLL is configured.

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

Thanks, Pavel, I just changed that a few minutes ago, no luck, I also see where P10 should probably be coded as an input but I had it as the same as P9. I also tried pulldown and pullupdown. Someone posted someplace else that I should be using HSE clock, haven't looked into that, but I would think tx wouldn't be working. My GPIO settings (that still don't work) are now:

 GPIO_InitTypeDef GPIO_InitStruct;

 GPIO_InitStruct.Pin     = GPIO_PIN_9;

 GPIO_InitStruct.Mode    = GPIO_MODE_AF_PP;

 GPIO_InitStruct.Pull    = GPIO_PULLUP;

 GPIO_InitStruct.Speed    = GPIO_SPEED_FREQ_HIGH;

 GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct);

 /* UART RX GPIO pin configuration */

 GPIO_InitStruct.Pin = GPIO_PIN_10;

 GPIO_InitStruct.Mode    = GPIO_MODE_INPUT; // was coded as GPIO_MODE_AF_PP;

 GPIO_InitStruct.Pull    = GPIO_NOPULL; // was coded as GPIO_PULLUP

 GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

jhanc.11
Senior

Pavel to answer your other question, the cube wants usart1 to be on PB6/7 and with no pull or down.

>  GPIO_InitStruct.Mode   = GPIO_MODE_INPUT; // was coded as GPIO_MODE_AF_PP;

Try to use the GPIO init code exactly as the cube generated it.

To compensate for inaccurate clock (before change to HSE) try lower baudrates. 9600.

jhanc.11
Senior

OK, I went back to check and now I see cube selected the F7 chip but not the correct board. I am going to gen a new project and see what happens. with the correct board, it now had Pa9 and 10 selected but it says usart1 is "partially disabled" whatever that means.

jhanc.11
Senior

thanks for the comments above. I went back to cube and now I can't get it to generate an IDE project even though it should be a simple selection. Now that cube has the right board pins, etc, I'd like to see what it would generate, and do you think I can get it to? The other projects built the same way show up as IDE in a little overlay on the folder when you open them in the IDE. This has none of the targets setup, etc. I mean, can it be made any more frustrating???

jhanc.11
Senior

OK, I take it all back. All my cursing, etc. The project I generated by selecting the board works, I mean it is now receiving and sending it back. The only major thing I see vs the mods I made with everyone's help, is the HSE clock instead of HSI. Otherwise everything generated by cube is pretty much my mods plus those recommended by others.

Thanks. Now where was I?

Jerry