cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030J6 Reset in loop

MCost.1
Associate

Hi, I have a STM32G030J6 with a trimpot connected to PA0 (NRST), but I need to disable NRST function. Based on pdf (UM2568) I write this:

<code>

uint32_t nrstmode;

 /* Enable Flash access anyway */

 __HAL_RCC_FLASH_CLK_ENABLE();

 /* Unlock flash */

 FLASH->KEYR = FLASH_KEY1;

 FLASH->KEYR = FLASH_KEY2;

 while((FLASH->CR & FLASH_CR_LOCK) != 0x00);

 /* unlock option byte registers */

 FLASH->OPTKEYR = 0x08192A3B;

 FLASH->OPTKEYR = 0x4C5D6E7F;

 while((FLASH->CR & FLASH_CR_OPTLOCK) == FLASH_CR_OPTLOCK);

HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 3, 0xFFFF);

 /* get current user option bytes */

 nrstmode = (FLASH->OPTR & ~FLASH_OPTR_NRST_MODE);

 /* Select sub demo mode */

  

  nrstmode |= OB_RESET_MODE_GPIO;

  

  //nrstmode |= OB_RESET_MODE_INPUT_OUTPUT;

  

 /* Program option bytes */

 FLASH->OPTR = nrstmode;

 /* Write operation */

 FLASH->CR |= FLASH_CR_OPTSTRT;

 while((FLASH->SR & FLASH_SR_BSY1) != 0);

 /* Force OB Load */

 FLASH->CR |= FLASH_CR_OBL_LAUNCH;

</code>

But now my chip is in a infinite reset loop, and I can't connect my st-link to erase/program.

1 REPLY 1
IKrav.1
Associate

Hello,

I would like to do similar things and use PA0 as GPIO.

Did you solve you your issue ?

Can in-circuit programming based on ST-Link work without NRST Pin ?

Best regards,

Ivan