cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-G0B1RE with SNK1M1 only DEFAULT 5V

kuda1311
Associate II

Hi STM32 community,

 

I have ordered those the Evalboards: 


NUCLEO-G0B1RE 

X-NUCLEO-SNK1M1 - USB Type-C Power Delivery Sink

 

 
I have followed all of your existing applications, but none of the had lead to an similar result as displayed by your application descriptions. 

Lets stick to the newest one:
(24) How to build an USBPD Sink application using the X-Cube-TCPP software pack - YouTube

I followed every step accurately several times now, but the result is always the same, Contract -> DEFAULT 5V no current. 
What am I doing wrong?

 I have studied all of your AN, watched all Videos, read and did the Wiki but never got any positive result as described..... Im frustrated and hoping for your help. 

Thank you very much! 

Br,
KUDA

The usbc_test_3.zip is the zipped project.




3 REPLIES 3
FBL
ST Employee

Hi @kuda1311 

Did you check this example as reference project?

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.


Hi kuda1311

Thank you for sharing your .ioc and project.

On my end, using the same hardware as you (STM32G0B1RE and SNK1M1), regenerating a project from your .ioc, the application works as expected.

However, I reproduce your problem if I remove the JP4-RESET jumper from the SNK1M1 shied.

So, for use with STM32CubeMonitor-UCPD, the jumper configuration should be as follows:

- For the Nucleo power selection : Jumper JP2 on "STLink"

- For the SNK1M1 shield : Jumper JP4-RESET present and Jumper JP5-LDO_OUT present

-----------------------

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.

 

 

Hi, I a already Figured it out. But Thank you for the response. I have an other issue at the moment. I cant use the GPIOD, VSSI02 is on 3.3V. Im using stm32g0b1kb. It wont toggle it wont read, it does nothing. What am I missing.



/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 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"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
void Check_VDDIO2_Status(void);
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */
uint8_t rd10_switch_ready = 0;
volatile uint32_t current_time = 0;
volatile uint32_t previous_time = 0;
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* 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();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  /* PWR-Clock sicherstellen (falls nicht schon in SystemClock_Config getan) */
  __HAL_RCC_PWR_CLK_ENABLE();

  /* VDDIO2 einmal definierte Reihenfolge: erst aus, dann an */
  HAL_PWREx_DisableVddIO2();
  HAL_Delay(10);

  HAL_PWREx_EnableVddIO2(); // aktiviert die Domäne per Software
  HAL_Delay(10);            // etwas Wartezeit
  Check_VDDIO2_Status();    // prüft das Status-Register
  HAL_SYSCFG_StrobeDBattpinsConfig(SYSCFG_CFGR1_UCPD2_STROBE);

  /* USER CODE END 2 */

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

          HAL_GPIO_TogglePin(iBIT1_GPIO_Port, iBIT1_Pin);
//      GPIO_PinState p2 = HAL_GPIO_ReadPin(iBIT2_GPIO_Port, iBIT2_Pin);
//      GPIO_PinState p3 = HAL_GPIO_ReadPin(iBIT3_GPIO_Port, iBIT3_Pin);
//      GPIO_PinState p4 = HAL_GPIO_ReadPin(iBIT4_GPIO_Port, iBIT4_Pin);

      /* Hier Breakpoint setzen und p1–p4 beobachten */
      HAL_Delay(100);

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
  RCC_OscInitStruct.PLL.PLLN = 8;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief GPIO Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  /* USER CODE BEGIN MX_GPIO_Init_1 */
  /* Ports aktivieren: hier minimal die Ports, auf denen deine iBIT-Pins liegen */
  /* Wenn z.B. iBIT1 auf GPIOB, iBIT4 auf GPIOD liegt, musst du beide aktivieren. */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOC_CLK_ENABLE();
  /* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin : iBIT1_Pin */
  GPIO_InitStruct.Pin = iBIT1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(iBIT1_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : iBIT2_Pin iBIT3_Pin */
  GPIO_InitStruct.Pin = iBIT2_Pin|iBIT3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  /*Configure GPIO pin : iBIT4_Pin */
  GPIO_InitStruct.Pin = iBIT4_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(iBIT4_GPIO_Port, &GPIO_InitStruct);

  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);

  /* USER CODE BEGIN MX_GPIO_Init_2 */
  /* iBIT1: Interrupt-Eingang (Rising) */
  GPIO_InitStruct.Pin = iBIT1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(iBIT1_GPIO_Port, &GPIO_InitStruct);

  /* iBIT2: normaler digitaler Eingang */
  GPIO_InitStruct.Pin = iBIT2_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(iBIT2_GPIO_Port, &GPIO_InitStruct);

  /* iBIT3: normaler digitaler Eingang (nicht analog, wenn du ihn lesen willst) */
  GPIO_InitStruct.Pin = iBIT3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(iBIT3_GPIO_Port, &GPIO_InitStruct);

  /* iBIT4: normaler digitaler Eingang */
  GPIO_InitStruct.Pin = iBIT4_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(iBIT4_GPIO_Port, &GPIO_InitStruct);

  /* EXTI interrupt init – nur nötig, wenn iBIT1 auch wirklich an EXTI0_1 hängt */
  HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
  /* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

void Check_VDDIO2_Status(void)
{
    uint32_t sr2 = PWR->SR2;

    /* Hier könntest du gezielt auf ein bestimmtes Bit prüfen, z.B.:
       if (sr2 & PWR_SR2_PVMO2) { ... } */

    if (sr2)
    {
        uint8_t a = 0;
        (void)a;
    }
    else
    {
        uint8_t a = 1;
        (void)a;
    }
}

/**
  * @brief  EXTI line rising detection callback.
  * @PAram  GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
{
    current_time = HAL_GetTick();

    if ((GPIO_Pin == iBIT1_Pin) && ((current_time - previous_time) > 100))
    {
        rd10_switch_ready = 1;
        previous_time = current_time;
    }
    else
    {
        rd10_switch_ready = 0;
    }
}

/**
  * @brief  EXTI line falling detection callback.
  * @PAram  GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
    current_time = HAL_GetTick();

    if ((GPIO_Pin == iBIT1_Pin) && ((current_time - previous_time) > 100))
    {
        rd10_switch_ready = 1;
        previous_time = current_time;
    }
    else
    {
        rd10_switch_ready = 0;
    }
}

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @PAram  file: pointer to the source file name
  * @PAram  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */