polona1010
Member level 1
Hello,
How to use internal eeprom memory of pic18f45k22 for reading and writing in MikroC.
How to use internal eeprom memory of pic18f45k22 for reading and writing in MikroC.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
EEPROM_Write(0x32, 0xAA);
unsigned short take;
...
take = EEPROM_Read(0x3F);
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #include <eeprom_routines.h> #define LED PORTBbits.RB0 void main(){ unsigned char eeppdat = 0; EEPROM_WRITE(0x00, 'K'); __delay_ms(20); eepdat = EEPROM_READ(0x00); if(eepdat == 'K')LED = 1; }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 EEPROM_Write(0x00,'8'); Delay_ms(20); EEPROM_Write(0x01,'H'); Delay_ms(20); EEPROM_Write(0x02,'7'); Delay_ms(20); EEPROM_Write(0x03,'G'); Delay_ms(20); EEPROM_Write(0x04,'6'); Delay_ms(20); EEPROM_Write(0x05,'F'; Delay_ms(20); EEPROM_Write(0x06,'5'); Delay_ms(20); EEPROM_Write(0x07,'E'); Delay_ms(20); EEPROM_Write(0x08,'4'); Delay_ms(20); EEPROM_Write(0x09,'D'); Delay_ms(20); EEPROM_Write(0x0A,'3'); Delay_ms(20); EEPROM_Write(0x0B,'C'); Delay_ms(20); EEPROM_Write(0x0B,'2'); Delay_ms(20); EEPROM_Write(0x0B,'B'); Delay_ms(20); EEPROM_Write(0x0B,'1'); Delay_ms(20); EEPROM_Write(0x0B,'A'); Delay_ms(20);
char eeprom_address;
eeprom_address = 0x10; // Starting position of eeprom address
for (i=0; i<8; i++) // Loop to shift 8 bytes
{
EEPROM_write(eeprom_address, 0xA1); // Writing data in eeprom
eeprom_address = eeprom_address + 1; // Move to one address place in eeprom
}
// Reading 8 bytes from internal memory of uC, address range 0x10-0x17
// Print on LCD display in HEX format
char eeprom_address;
char eeprom_value_hex;
char eeprom_value;
char i; // Loop variable
int colona;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1, 1, "HEX FORMAT");
colona = 1; // Used to set starting column on lcd
eeprom_address = 0x10; // Starting position of eeprom address
for (i=0; i<8; i++) // Loop to shift 8 bytes
{
eeprom_value = EEPROM_read(eeprom_address); // Read eeprom address
ByteToHex(eeprom_value, eeprom_value_hex); // Convert byte value to hex format
Lcd_Out(2, colona, eeprom_value_hex); // Show HEX value of eeprom
colona = colona + 2; // Move to 2 places on right
eeprom_address = eeprom_address + 1; // Move to one address place in eeprom
}
EEPROM_write(0x20, 0xFF);
EEPROM_write(0x20, 0xA1);
EEPROM_write(0x20, 0xA1);
Delay_ms(20);
eeprom_value = EEPROM_read(0x20);