Microcontroller question

In summary, microcontroller programmers using assembly should be familiar with the internal EEPROM, specifically the register EECON2. This register must be initialized with the values 0x55 and 0xAA before writing to prevent runaway code execution. These values were chosen because they are opposite in binary and the register is not a physical one. This information can be found in section 7.4 of the PIC18F datasheet.
  • #1
Magna Visus
24
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
  • #2
It's to help prevent runaway code execution from overwriting the eeprom.
 
  • #3
Thanks!

But why use 0x55 and 0xAA why not some other random hex numbers?
 
  • #4
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
 
  • #5
That's what I ment, the values were perfectly opposite (I mean NOT(01010101) is 10101010).
Anyways thanks for the answer and link
 

1. What is a microcontroller?

A microcontroller is a small computer on a single integrated circuit that is designed to control a specific task or system. It contains a processor, memory, and input/output peripherals, and is commonly used in electronic devices such as appliances, automobiles, and industrial control systems.

2. What are the main components of a microcontroller?

The main components of a microcontroller include a central processing unit (CPU), memory, input/output (I/O) ports, timers, and interrupts. The CPU is responsible for executing instructions and controlling the overall operation of the microcontroller, while the memory stores the program and data. The I/O ports allow the microcontroller to communicate with external devices, and the timers and interrupts help to manage the timing and flow of the program.

3. How is a microcontroller different from a microprocessor?

A microcontroller is different from a microprocessor in that it is a complete system on a single chip, whereas a microprocessor requires external components such as memory and I/O devices to function. Microcontrollers are also designed for specific tasks and have built-in features such as timers and interrupts, while microprocessors are more general-purpose and require additional components for these functions.

4. What are some common applications of microcontrollers?

Microcontrollers have a wide range of applications, including consumer electronics, medical devices, automotive systems, and industrial control systems. They are commonly used in devices that require precise control and monitoring, such as thermostats, remote controls, and traffic lights.

5. How do I program a microcontroller?

Microcontrollers are typically programmed using specialized software and programming languages such as C or assembly language. The program is written on a computer and then transferred to the microcontroller using a programmer. Some microcontrollers also have the ability to be programmed in a graphical programming language, making it easier for beginners to get started.

Similar threads

  • Electrical Engineering
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • STEM Academic Advising
Replies
16
Views
667
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Sci-Fi Writing and World Building
Replies
12
Views
354
  • STEM Academic Advising
Replies
13
Views
659
  • STEM Academic Advising
Replies
1
Views
1K
  • STEM Career Guidance
Replies
4
Views
1K
Replies
19
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top