Skip to main content
This topic has been closed for replies.
Best answer by STTwo-32

Hello @Yang Yang @Elatewendy 

According to the part 10.7.12 of the RM0456, "When PA11 and PA12 are used as standard GPIOs, USBPWREN and VDD11USBDIS bits in PWR_VOSR must be set prior to configure the GPIOs in a mode other than analog".

STTwo32_0-1708672377232.png

 

Best Regards.

STTwo-32

5 replies

Explorer II
February 23, 2024

Hi,

I encountered the issue about PA11 and PA12 a month ago. I couldn't find a solution, so I asked our hardware designer to modify the circuit diagram and replace  with another GPIOs.:face_with_tears_of_joy:

 

GoodLuck!

STTwo-32Answer
Technical Moderator
February 23, 2024

Hello @Yang Yang @Elatewendy 

According to the part 10.7.12 of the RM0456, "When PA11 and PA12 are used as standard GPIOs, USBPWREN and VDD11USBDIS bits in PWR_VOSR must be set prior to configure the GPIOs in a mode other than analog".

STTwo32_0-1708672377232.png

 

Best Regards.

STTwo-32

Explorer II
February 23, 2024

hello,@STTwo-32.

I asked the same question at https://community.st.com/t5/stm32-mcus-products/stm32u595-used-pa12-and-pa11-as-input-gpios-can-t-get-the-high/td-p/635837 .

 

I made a mini project to read the registers.The GPIOA register are ZERO...

The result like as:

HW VERSION 001001
reg_pwr_init = 0x7c000
reg_pwr = 0x2fc000
reg_gpioa = 0x6700

Elatewendy_0-1708673166943.png

#define HW_BIT0 HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_7)
#define HW_BIT1 HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8)
#define HW_BIT2 HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_9)
#define HW_BIT3 HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_8)
#define HW_BIT4 HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11)
#define HW_BIT5 HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_12)

int main(void)
{
 /* USER CODE BEGIN 1 */
	uint32_t reg_pwr_init;
	uint32_t reg_pwr;
 uint32_t reg_gpio;

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */
 SystemClock_Config();

 /* Configure the System Power */
 SystemPower_Config();

 /* USER CODE BEGIN SysInit */
	reg_pwr_init = READ_REG(PWR->VOSR);
	SET_BIT(PWR->CR1 , PWR_CR1_FORCE_USBPWR);
	SET_BIT(PWR->VOSR, (PWR_VOSR_USBPWREN | PWR_VOSR_USBBOOSTEN));
	SET_BIT(PWR->VOSR, PWR_VOSR_VDD11USBDIS);

 
 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_USART1_UART_Init();
 MX_ICACHE_Init();
 /* USER CODE BEGIN 2 */
	reg_pwr = READ_REG(PWR->VOSR);
	reg_gpio = READ_REG(GPIOA->IDR);
	printf("HW VERSION %d%d%d%d%d%d\r\n",HW_BIT5,HW_BIT4,HW_BIT3,HW_BIT2,HW_BIT1,HW_BIT0);
	printf("reg_pwr_init = 0x%x\r\n",reg_pwr_init);
	printf("reg_pwr = 0x%x\r\n",reg_pwr);
	printf("reg_gpioa = 0x%x\r\n",reg_gpio);
 /* USER CODE END 2 */

 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_SET);
		HAL_Delay(1000);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_RESET);
		HAL_Delay(1000);
 }
 /* USER CODE END 3 */
}

 

 

 

 

 

 

And the gpios configured like this:

Elatewendy_1-1708673347714.png

 

 

Yang YangAuthor
Visitor II
February 24, 2024

Hello, @STTwo-32 @Elatewendy 

 

Thanks for your quick reply.

I had a similar code as @Elatewendy  did in his post. And PA12 is logic low level, it seems GPIO setting is failed. 

Do I miss something? And also I will check my conclusion again these days.

 

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */
SET_BIT(PWR->VOSR, PWR_VOSR_VDD11USBDIS);
SET_BIT(PWR->VOSR, PWR_VOSR_USBPWREN);
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
pa12_state = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_12);
if(pa12_state == GPIO_PIN_RESET)
usb_mode_flag = 1;
/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_GPDMA1_Init();
MX_DAC1_Init();

 

 

BR

Yang

Yang YangAuthor
Visitor II
February 27, 2024

Hello, @STTwo-32 

 

I have checked again, and still PA12 can not be set as GPIO input. The voltage in this pin is about 0.4V, it seems still this pin works on USB related function. Any idea about this?

 

BR

Yang

Visitor II
April 11, 2024

Hello,

try this solution:

Solved: Problem with Pin A11 on STM32U595VJ - STMicroelectronics Community

Should be the same problem with USB stuff on PA11/12...

Explorer II
April 11, 2024

Thanks @SStor 

 

I tested it and found that this method is effective.