Please,
I am trying to use the EEPROM function but the software lockup after the use this function. Anyone can help me?
Thanks in advance!
Jorge
//------------------------------------------------------
char *text = "CONTADOR LCD";
unsigned char uni=0,j=20;
void main(){
TRISC = 0;
trisb = 0xff;
LCD_INIT(&PORTC);
LCD_CMD(LCD_CLEAR);
LCD_CMD(LCD_CURSOR_OFF);
LCD_OUT(1,1,text);
LCD_chr(2,5,48+uni);
while(1){
if (Button(&PORTB,4,1,0))
{
delay_ms(500);
uni++;
LCD_chr(2,5,48+uni);
if (uni==9)
uni=0;
}
if (Button(&PORTB,5,1,0))
{
EEprom_Write(j, uni); // Software lockup here
delay_ms(500);
}
if (Button(&PORTB,6,1,0))
{
uni= EEPROM_Read(j);
delay_ms(500);
LCD_chr(2,5,48+uni);
}
}
}
EEPROM_WRITE Function
-
- Posts: 6
- Joined: 04 Jun 2005 23:48
- Location: Brasil
You have assigned both uni and j as a constant, I can understand j as the eeprom address, however uni is what you put in the address, in this case "0" have you tried to make uni a varible and give it a value within the program
I have writen code to read and write to the eeprom in pascal and yes I did use a value for the eeprom address, however used a vaviable to store in the eeprom address location.
Andrew
Code: Select all
unsigned char j=20; // have you tried using unsigned short (int)
unsigned char uni;
...
.
...
void main(){
TRISC = 0;
trisb = 0xff;
uni = 0; // variable value for uni.
LCD_INIT(&PORTC);
LCD_CMD(LCD_CLEAR);
LCD_CMD(LCD_CURSOR_OFF);
LCD_OUT(1,1,text);
LCD_chr(2,5,48+uni);
while(1){
if (Button(&PORTB,4,1,0))
{
delay_ms(500);
uni++;
LCD_chr(2,5,48+uni);
if (uni==9)
uni=0;
}
Andrew