Skip to main content
Explorer II
February 5, 2024
Solved

STM32U595 used PA12 and PA11 as INPUT gpios,can't get the HIGH level

  • February 5, 2024
  • 5 replies
  • 2294 views

Hi,I used PA12 & PA11 as input gpios(pull-up) in STM32U595VJT6Q ,read the pins are always '0'.The IOs connected NOTHING.

I reference RM0456 :

Elatewendy_0-1707126649153.png

 

I config USBPWREN and VDD11USBDIS bits used the HAL functions before  GPIO_Init():

HAL_PWREx_EnableUSBHSTranceiverSupply();
HAL_PWREx_DisableVDD11USB();

BUT I read the pins still '0'.How can i do?

The details of HAL function like as:

HAL_StatusTypeDef HAL_PWREx_EnableUSBHSTranceiverSupply(void)
{
uint32_t vos;

/* Get the system applied voltage scaling range */
vos = HAL_PWREx_GetVoltageRange();

/* Check the system applied voltage scaling range */
if ((vos == PWR_REGULATOR_VOLTAGE_SCALE1) || (vos == PWR_REGULATOR_VOLTAGE_SCALE2))
{
SET_BIT(PWR->VOSR, (PWR_VOSR_USBPWREN | PWR_VOSR_USBBOOSTEN));
}
else
{
return HAL_ERROR;
}

return HAL_OK;
}

 

void HAL_PWREx_DisableVDD11USB(void)
{
/* Set VDD11USBDIS bit */
SET_BIT(PWR->VOSR, PWR_VOSR_VDD11USBDIS);
}

 

    This topic has been closed for replies.
    Best answer by Elatewendy

    Thanks @SStor 

    Solved: Problem with Pin A11 on STM32U595VJ - STMicroelectronics Community

     

    This method is effective.

    SET_BIT(PWR->SVMCR, PWR_SVMCR_USV);
    SET_BIT(PWR->VOSR, PWR_VOSR_USBPWREN | PWR_VOSR_VDD11USBDIS);

    Elatewendy_0-1712807099074.png

     

     

    5 replies

    Super User
    February 5, 2024

    Use this button to properly post source code:

    AndrewNeil_0-1707132633542.png

     

    To get that extra row of icons, press this button:

    AndrewNeil_1-1707132633544.png

    Explorer II
    February 6, 2024

    thank you very much.I have learned:handshake:

    Super User
    February 5, 2024

    Read out PWR_VOSR content and check those two bits in it. If they are not set, check if you've enabled clock for PWR in RCC.

    If that's OK, read out and check GPIO registers content.

    JW

    Explorer II
    February 6, 2024

    Thanks for your reply.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-1707201293012.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->VOSR,PWR_VOSR_USBPWREN);
    	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 */
    }

     

    Super User
    February 6, 2024

    I'd have a look also at GPIOA->MODER, whether both PA11 and PA12 are set as outputs.

    Beyond that, sorry, I don't know what else to check.

    JW

    Explorer II
    February 7, 2024

    Hi,my project is created by CubeMx.

    The GPIO configured like as:

    Elatewendy_0-1707286766052.png

     

     

    ElatewendyAuthorAnswer
    Explorer II
    April 11, 2024

    Thanks @SStor 

    Solved: Problem with Pin A11 on STM32U595VJ - STMicroelectronics Community

     

    This method is effective.

    SET_BIT(PWR->SVMCR, PWR_SVMCR_USV);
    SET_BIT(PWR->VOSR, PWR_VOSR_USBPWREN | PWR_VOSR_VDD11USBDIS);

    Elatewendy_0-1712807099074.png

     

     

    Super User
    April 11, 2024

    Oh, an isolation switch... Thanks with coming back with the solution.

    JW