2024-02-23 1:10 AM - edited 2024-02-23 1:10 AM
Hi everyone,
Recently started working on STM32C011J4M3 micro. I'm trying to set PF2-NRST pin as a GPIO. but when I configure it from cube MX as GPIO PIN always reamins in High state that is a 3.28v and i'm unable to toggle the pin or perform any other operation.
int main(void)
{
/* USER CODE BEGIN 1 */
// SET_BIT(FLASH->OPTR,FLASH_OPTR_NRST_MODE_1);
WRITE_REG(FLASH->OPTR,0x2UL << 027U); // Even tried stting nrst mode2.
/* 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 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_2, GPIO_PIN_RESET);
HAL_Delay(3000);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_2, GPIO_PIN_SET);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
can anyone help me with this,
do I need to add any push-up/pull down specifically to this pin to use as GPIO?
Solved! Go to Solution.
2025-03-11 5:21 AM
@AdamZ thanks for the respose.
But this does not work for production. why to add additional step when you can handle this from code. you cannot configure each and every controller during production. plus this requires reliance on ST link debugger and does not work with Jlink. while most professionals used Jlink as standard programming tool.