cancel
Showing results for 
Search instead for 
Did you mean: 

The question about RDP(STM32F401RE)

aizhixi
Associate II
Posted on July 27, 2016 at 11:13

Hi:

I used STM32F401RE nuclo board test RDP found that if i changed RDP level0 to level1 ,the code can't run.

At the same time,i used the st-link utility to test it,found same question,i download the hex(LED demo) then update option bytes.At the end, reboot mcu by power up again,the code also can't run,i don't know why.i check the reference manual, can't found problem.

Used st-link

utility

has problem,so i wanna use register to set the RDP level.follow is code:

int main(void)

{

  /* This sample code shows how to use STM32F4xx GPIO HAL API to toggle PA05 IOs 

  connected to LED2 on STM32F4xx-Nucleo board  

  in an infinite loop.

  To proceed, 3 steps are required: */

  

  /* STM32F4xx HAL library initialization:

  - Configure the Flash prefetch, instruction and Data caches

  - Configure the Systick to generate an interrupt each 1 msec

  - Set NVIC Group Priority to 4

  - Global MSP (MCU Support Package) initialization

  */

  

  HAL_Init(); 

  /* Configure the system clock to 84 MHz */

  SystemClock_Config();  

  /* -1- Enable GPIOA Clock (to be able to program the configuration registers) */

  __HAL_RCC_GPIOA_CLK_ENABLE(); 

  /* -2- Configure PA05 IO in output push-pull mode to

  drive external LED */

  GPIO_InitStruct.Pin = GPIO_PIN_5;

  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStruct.Pull = GPIO_PULLUP;

  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 

  HAL_FLASHEx_OBGetConfig(&myOp);

 

  if((myOp.RDPLevel&0xff)!=0xbb)

  {

    HAL_FLASH_Unlock();

    HAL_FLASH_OB_Unlock();

    

    myConfigOption();//

    //    myOp.OptionType = OPTIONBYTE_RDP;

    //    myOp.RDPLevel =tmp2;//0xff;//

    //    HAL_FLASHEx_OBProgram(&myOp);

    // FLASH->OPTCR|=FLASH_OPTCR_OPTSTRT;

    HAL_FLASH_OB_Launch();

    HAL_FLASH_OB_Lock();

    HAL_FLASH_Lock(); 

  }

  

  /* -3- Toggle PA05 IO in an infinite loop */  

  while (1)

  {

    HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

    

    /* Insert delay 100 ms */

    HAL_Delay(100);

  }

}

void myConfigOption()

{

    FLASH_OB_RDP_LevelConfig(0xBB);

    //FLASH_OB_BOR_LevelConfig(OB_BOR_LEVEL2);

  

}

I can't find any problem, so i'm not sure where the problem is?

Can you help me?

Hardware ST Nuclo board STM32F401RE

IDE?IAR 7.4

Firmware: STM32Cube1.9

Tks 

BR

Roy    

#stm32f401
1 REPLY 1
Posted on July 27, 2016 at 14:13

I'd probably use a USART, or more GPIO outputs/modes, to try an gather how deep into the code it was getting, and report on the internal state as the device sees it .

My guess is that it is in a loop trying to get it into the option state you want.

You aren't going to be able to use a debugger.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..