use of eeprom memory area of PICs

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
fransky
Posts: 10
Joined: Mon Nov 28, 2005 10:00 am
Contact:

use of eeprom memory area of PICs

Post by fransky »

Hi there,

I'm developing an application where it would be neccessary that if power is turned off and on again after that, the application returns to the state it was in before the mains shut off.

I use a 16F88 PIC, from the datasheet I learned that there's an EEPROM area available that could be used to store the application settings after a user action so I could retrieve the last operational settings from there upon a power up.

My question: How can I address such EEPROM and store/retrieve variables from within flowcode?

best regards, Fransky

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Been thanked: 1 time
Contact:

Post by Ian »

There is an EEPROM component in the Professional pack if you have that version.

You can also use embedded C Code as well
the following should help you with creating your own EPROM code.

char FCD_EEPROM0_EEPROMRead(char addr)
{
//GetEEPROMReadCode

char data = 0;
#ifdef MX_EE
eeadr = addr;
#ifdef MX_EE_TYPE2
clear_bit(eecon1, EEPGD);
#endif
set_bit(eecon1, RD);
data = eedata;
#else
#ifdef MX_EE_TYPE67X
asm error "FlowCode does not support EEPROM for this device"
#else
#ifdef MX_EE_TYPE62X
asm error "FlowCode does not support EEPROM for this device"
#else
asm error "Chip does not have EEPROM memory"
#endif
#endif
#endif
return (data);
}

void FCD_EEPROM0_WriteEEPROM(char addr, char data)
{
//GetEEPROMWriteCode

#ifdef MX_EE
//wait for previous EE writes to complete...
while ((eecon1 & 0x02) == 0x02);

eeadr = addr;
eedata = data;
#ifdef MX_EE_TYPE2
clear_bit(eecon1, EEPGD);
#endif
set_bit(eecon1, WREN);
clear_bit(intcon, GIE);
eecon2 = 0x55;
eecon2 = 0xAA;
set_bit(eecon1, WR);
set_bit(intcon, GIE);
clear_bit(eecon1, WREN);
#else
#ifdef MX_EE_TYPE67X
asm error "FlowCode does not support EEPROM for this device"
#else
#ifdef MX_EE_TYPE62X
asm error "FlowCode does not support EEPROM for this device"
#else
asm error "Chip does not have EEPROM memory"
#endif
#endif
#endif
}



FCD_EEPROM0_WriteEEPROM(25, 32);
FCV_EEP = FCD_EEPROM0_EEPROMRead(25);

Post Reply