Skip to main content
Llu.1
Associate
July 17, 2020
Question

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

  • July 17, 2020
  • 3 replies
  • 1342 views

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.

3 replies

TDK
Super User
July 17, 2020

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
July 22, 2020

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
July 22, 2020

It's L1, not L5 series...

TDK
Super User
July 22, 2020

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
July 22, 2020

> MCU stops working

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

JW