Skip to main content
Llu.1
Associate
Jul 17, 2020 9:29 AM UTC
Question

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

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();

}

This topic has been closed for replies.

5 replies

TDK
Jul 17, 2020 12:53 PM UTC

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""."
Llu.1
Llu.1Author
Associate
Jul 22, 2020 5:06 AM UTC

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!

​

Piranha
Principal III
Jul 22, 2020 8:36 PM UTC

It's L1, not L5 series...

TDK
Jul 22, 2020 12:54 PM UTC

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""."
waclawek.jan
Super User
Jul 22, 2020 8:13 PM UTC

> MCU stops working

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

JW