2022-11-23 08:37 PM
I am using for instance, ADC, UARTS, Timers, external interrupts, etc., all generated with cube. But I notice that cube doesn't always generate GPIO settings for certain pins. For instance, ADC1_IN4, when I select it using my board, an stm32f769i-disco, PIN PA4 is populated and not marked as modified in the GPIO section. When I look at the code generated by cube in the GPIO init section, there is no mention of that pin. This is also the case for TIM3_CH3 where PA6 is again preselected by cube and no GPIO entries are setup (in the generated code). lastly, usart1 follows the same pattern, where PA9 and PA10 are predetermined and no GPIO settings are generated in the resulting code. Does this this have to do with me selecting the stm32f769i-disco board and it defaulting the pins to specific functions? This is driving me crazy because certain pins can be used on more than one function (alternate functions) and with the board limitations, I am needing other pins.
Lastly, I went through the GPIO section port by port and made a map of the PINs that are called out (In GPIO init) and the Timer3, ADC and Usart pins are not coded (in GPIOO) but clearly the functions work. What am I missing here?
Thank
Jerry
Solved! Go to Solution.
2022-11-24 01:52 AM
Go figure, I told cubemx to generate separate files (c & h for each) and it added all the GPIO initialization in each file. there is clearly something wrong with the mac version I'm running. I thought I was going crazy because simple things just weren't working. The files look ok now, thanks
2022-11-24 02:10 AM
Great!
If the problem is solved, please mark this thread as answered by selecting Select as best, as also explained here. This will help other users find that answer faster.
Good luck!
/Peter
2022-11-24 09:33 AM
You dont read and search carefuly. HAL_UART_MspInit and other peripherals gpio is in MSP file, not in main MX.
2022-11-24 10:10 AM
It doesn't take much effort to search the files and I searched for all the HAL_GPIO_Init entries. Here's the content of my msp file generated by cube. Plus there are no calls to anything I haven't traced. I mean there could be, but I haven't found it. I had to take a few spaces out but otherwise it is complete as generated. There is something wrong withe cube for the mac. In addition to this issue, you can't enter labels on the pins in GPIO, the text gets reversed so if you enter, TIM3_PIN_2 it gets entered, 2_NIP_3MIT and then it gives you an error that it begins with a number and then you pretty much can't get out of it.
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f7xx_hal_msp.c
* @brief This file provides code for the MSP Initialization
* and de-Initialization codes.
******************************************************************************
* @attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN Define */
/* USER CODE END Define */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN Macro */
/* USER CODE END Macro */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* External functions --------------------------------------------------------*/
/* USER CODE BEGIN ExternalFunctions */
/* USER CODE END ExternalFunctions */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_RCC_SYSCFG_CLK_ENABLE();
/* System interrupt init*/
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
2022-11-25 10:30 AM
Here's more information. A person above, MM something, can't see the rest, mentioned about the MSP file. That made sense, but as I posted above, the MSP file in my most recent project was pretty much blank. But I went back and looked at other projects and see that the MSP file, which again I didn't know about, was actually filled in. So cube isn't fully broken, but something in several of my projects is causing cube to not generate that file correctly. I'm not getting any errors, just missing the GPIO initialization.
2022-11-25 11:39 AM
Yes cube have many bugs. Sometimes you need generate code twice , on first is msp and it not filled...