cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f407 Can't turn on led after power reset due to (calling a function _writing to flash_)

mahmuudesam
Associate II
Posted on March 24, 2015 at 16:34

I wrote a very simple code to test effect of writing to flash on other lines on the code. I tested turning on the led .

It's turned on while running. But after power reset it's turned off. What may be the problem in that?

__attribute__((__section__(''.user_data''))) const uint32_t userConfig[64];

uint32_t testwritevalue=6;

HAL_StatusTypeDef status = HAL_ERROR;

void testwriteFlash(void)

{

HAL_StatusTypeDef status;

status = HAL_FLASH_Unlock(); // returns

HAL

_OK

FLASH_Erase_Sector(FLASH_SECTOR_2, VOLTAGE_RANGE_1);

status = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, (uint32_t) userConfig, (uint64_t)testwritevalue);

// returns

HAL

_OK

status = HAL_FLASH_Lock();

// returns

HAL

_OK

}

int main(void)

{

HAL_Init(); // initialization

SystemClock_Config();

// initialization

MX_GPIO_Init();

// initialization

HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,0);

// turn on the yellow led

testwriteFlash();

while (1)

{}

}

Thanks in advance

0690X0000060Mn8QAE.gif

5 REPLIES 5
Posted on March 24, 2015 at 17:41

How large is your total code/image footprint? See .MAP, linker output, etc.

Is your board really powered at 1.8V - 2.1V?

Is BOOT0 Low?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mahmuudesam
Associate II
Posted on March 24, 2015 at 18:05

About the power it's powered at 3.3V and I tried all voltage ranges 1,2,3 with the same problem

BOOT0 is connected to GND through a (12.4K  resistor)

About the code size

   

text       data        bss        dec        hex        filename

     8933      384        456       9773      262d     test_flash_24_3_2015.elf

About the .map file, it contains the following

Memory Configuration

Name                       Origin                              Length             Attributes

FLASH1         0x0000000008000000 0x0000000000008000      xr

DATA             0x0000000008008000 0x0000000000004000     xrw

FLASH           0x000000000800c000 0x0000000000074000     xr

 

 

this is the part of the linker for the user configured flash

MEMORY   

{

// RAM 

default

  FLASH1 (rx) : ORIGIN = 0x08000000, LENGTH = 32k

  DATA (xrw) : ORIGIN = 0x08008000, LENGTH = 16k        

  FLASH (rx) : ORIGIN = 0x0800C000, LENGTH = 512K-48k 

//others default

}

SECTIONS

{

    .user_data :

    {

      . = ALIGN(4);

         *(.user_data)

      . = ALIGN(4);

    } > DATA

}

jagdishk741
Associate
Posted on March 24, 2015 at 18:30

Hi Clive,

I'm trying to interface my GPS board (SKG13C) with STM32F407 using usart as part of my project. The result should be in NMEA format. Is there any code available?

I'm not that good with coding, but I can understand the code upto some extent.

Cn u help me out.,?
Posted on March 24, 2015 at 19:44

I'm trying to interface my GPS board (SKG13C) with STM32F407 using usart as part of my project. The result should be in NMEA format. Is there any code available?

 

I'm not that good with coding, but I can understand the code upto some extent.

 

Cn u help me out.,?

Wildly off-topic, I posted a worked NMEA parsing example in [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Issue%20with%20USART%20RX%20buffer%20and%20char%20filter&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=127]this thread.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 24, 2015 at 19:46

About the .map file, it contains the following

So not a size thing, as I suggested before it's import to code in a way that receives the status from the routines, and doesn't proceed doing things if the prior step failed.

Get a serial port on your board so you can output actionable diagnostic information.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..