How to use inbuilt EEPROM of PIC18F4550 Microcontroller
The EEPROM (ELECTRICALLY ERASABLE PROGRAMMABLE READ ONLY MEMORY) is a very useful memory which can be used for storing data. The data storing and retrieving from any EEPROM memory is very simple compared to other kind of memories. As the name suggest the memory is electrically programmable and hence the data will be sustained in the memory until it is electrically erased or reprogrammed.
There are lots of EEPROM chips available most of them are easy to interface with a microcontroller. It would be even better if the microcontroller itself has a built-in EEPROM. The microcontroller used in this project is PIC18F4550 and it also has an inbuilt EEPROM memory other than the flash memory. The data can be easily stored into or retrieve using simple codes.
The project mainly has two parts, a serial communication part and EEPROM accessing part. The data which should be written into the EEPROM is received from the serial port. The internal hardware module USART is used for this purpose. The data which is read from the EEPROM is also send back to the serial port using the same hardware module.
Hence two internal modules of the PIC18F4550 are used in this project namely EEPROM and USART. These hardware modules can be accessed and controller by simply writing into or reading from their corresponding registers.
The important control registers associated with the USART and their details are given below:
TXSTA: TRANSMIT STATUS AND CONTROL REGISTER
This register has the bits which controls the serial transmission features like enable or disable the transmission, whether it should be synchronous asynchronous etc.
For a simple asynchronous serial transmission only two bits are significant, which are TXEN and SYNC
TXEN is the transmission enable/disable bit and SYNC sets the synchronous/asynchronous mode.
TXEN: Transmit Enable
1 = Transmit enabled
0 = Transmit disabled
SYNC: EUSART Mode Select bit
1 = Synchronous mode
0 = Asynchronous mode
RCSTA: RECEIVE STATUS AND CONTROL REGISTER
This register has the bits which controls the serial reception features like enable/disable the serial port, reception should be 8 bit or 9 bit, whether it should be synchronous asynchronous, enable/disable continuous reception etc.
For a simple asynchronous serial reception the significant bits are SPEN, RX9 and CREN.
SPEN: Serial Port Enable bit
1 = Serial port enabled
0 = Serial port disabled
RX9: 9-Bit Receive Enable bit
1 = Selects 9-bit reception
0 = Selects 8-bit reception
CREN: Continuous Receive Enable bit
1 = Enables receiver
0 = Disables receiver
SPBRG: EUSART BAUD RATE GENERATOR REGISTER
This is a 16 bit register into which the value corresponding to the required baud-rate can be written into. The value according to a particular baud-rate can be calculated from the CPU clock frequency according to the following equation;
SPBRG = ((FOSC/Desired Baud Rate)/64) – 1
Where; FOSC is the CPU clock frequency
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test
Current Project / Post can also be found using:
- eeprom address pic18f4550
- PIC 18F eeprom
- pic18 inbuilt eeprom