cancel
Showing results for 
Search instead for 
Did you mean: 

Aa error occurs when the internal EEPROM(0x08080000) is written to 0x00

Llu.1
Associate

The following test code, when writing pTemp[3] to EEPROM, that is, when writing 0x00 to internal EEPROM(FLASH 0x08080000), an error will occur. Calling library function DATA_EEPROM_ProgramByte will have the same error. What causes it? Will it be due to insufficient voltage or grounding?

void EEPROM_WriteBytes(uint32_t Address, uint8_t *Buffer, uint16_t Length)

{

uint32_t i = 0;

//uint8_t *pTemp = (uint8_t *)Buffer;

uint8_t pTemp[5] = {0x01, 0x02, 0x00, 0x04, 0x00};

uint8_t *wAddr = (uint8_t *)(Address + EEPROM_BASE_ADDR);

uint8_t value = 0;

if(Length >= EEPROM_BYTE_SIZE)

{

Length = EEPROM_BYTE_SIZE;

}

__disable_irq();

DATA_EEPROM_Unlock();

for(i = 0; i < 5; i++)

{

value = *(pTemp + i);

*(__IO uint8_t *)(wAddr + i) = value;

//DATA_EEPROM_ProgramByte(wAddr + i, value);

}

DATA_EEPROM_Lock();

__enable_irq();

}

5 REPLIES 5
TDK
Guru

Always include your chip part number in your post.

> an error will occur

What error?

If you feel a post has answered your question, please click "Accept as Solution".

The device is STM32L151CB.

An error will writing 0x00 to the internal EEPROM (0x08080000).

There is no error prompt, MCU stops working.

What causes it?  Thank you!

TDK
Guru

That's not a valid memory address. The chip has 128kB of flash. You're writing well past the end of it.

Not sure.

If you feel a post has answered your question, please click "Accept as Solution".

> MCU stops working

Debug as usually. Instrument your programming code, as well as hardfault handler, and observe.

JW

It's L1, not L5 series...