Why Must EECON2 Be Initialized with 0x55 and 0xAA in PIC18F EEPROM Programming?

  • Thread starter Thread starter Magna Visus
  • Start date Start date
  • Tags Tags
    Microcontroller
Click For Summary

Discussion Overview

The discussion revolves around the initialization of the EECON2 register in the PIC18F microcontroller's EEPROM programming. Participants explore the reasons for using specific values (0x55 and 0xAA) and the implications of these choices in the context of microcontroller design and operation.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant notes that EECON2 must be initialized with 0x55 and 0xAA to prevent runaway code execution from overwriting the EEPROM.
  • Another participant questions why specifically 0x55 and 0xAA are used, suggesting that other random hex numbers could be alternatives.
  • A response indicates that the choice of these values is due to the design of the chip, implying that it is not arbitrary.
  • It is mentioned that the binary representations of 0x55 (01010101) and 0xAA (10101010) are complementary, which may have significance in the design.
  • A participant references a technical document to support their points about the register's function and design.

Areas of Agreement / Disagreement

Participants express differing views on the rationale behind the specific values used for EECON2 initialization, with some agreeing on the design aspect while others question the necessity of those particular values.

Contextual Notes

There is an implication that the design choices may depend on specific operational requirements of the microcontroller, but these assumptions are not fully explored or resolved in the discussion.

Magna Visus
Messages
23
Reaction score
0
Hello all,

Those who usually program microcontrollers in assembly, should be well familiar with the internal EEPROM (Series PIC18F).

In particular there's a register EECON2, that needs to be initialized ALWAYS with 0x55 then 0xAA before writing;
Why is that? What's the main reason behind these proper values?

Thanks.
 
Engineering news on Phys.org
It's to help prevent runaway code execution from overwriting the eeprom.
 
Thanks!

But why use 0x55 and 0xAA why not some other random hex numbers?
 
Because that is how the chip was designed to work. There isn't the answer to a question about life, the universe, and everything here.

Of course it's probably not a coincidence that two values are 01010101 and 10101010 in binary. And EECON2 is not a physical register either. http://ww1.microchip.com/downloads/en/DeviceDoc/31007a.pdf section 7.4
 
That's what I ment, the values were perfectly opposite (I mean NOT(01010101) is 10101010).
Anyways thanks for the answer and link
 

Similar threads

  • Sticky
  • · Replies 13 ·
Replies
13
Views
8K
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 71 ·
3
Replies
71
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K