2024-02-22 07:17 PM
Hello ST experts
I found the same problem as previous post https://community.st.com/t5/stm32-mcus-embedded-software/stm32f072xb-gpio-issue-usb-pins-do-not-work-as-gpio/m-p/151104#M8715
But for stm32u595, I can not find the similar register USB_CNTR.PDWN. Is there any way to set PA12 as GPIO input?
Best Regards
Yang
Solved! Go to Solution.
2024-02-22 11:13 PM - edited 2024-02-22 11:17 PM
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".
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-22 11:04 PM
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!
2024-02-22 11:13 PM - edited 2024-02-22 11:17 PM
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".
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-22 11:30 PM
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
#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:
2024-02-23 04:54 PM
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
2024-02-26 07:39 PM
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
2024-04-10 05:16 PM
Hello,
try this solution:
Solved: Problem with Pin A11 on STM32U595VJ - STMicroelectronics Community
Should be the same problem with USB stuff on PA11/12...
2024-04-10 08:49 PM