EEPROM_WRITE Function

General discussion on mikroC.
Post Reply
Author
Message
Jorgebrazil
Posts: 6
Joined: 04 Jun 2005 23:48
Location: Brasil

EEPROM_WRITE Function

#1 Post by Jorgebrazil » 26 Jul 2005 06:14

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);
}
}
}

Storic
Posts: 393
Joined: 01 Oct 2004 00:20
Location: Australia (S.A.)

#2 Post by Storic » 26 Jul 2005 06:20

What is "j", Have you tryed to replace j with a number (I assume this is your eeprom memory location.

Andrew

Jorgebrazil
Posts: 6
Joined: 04 Jun 2005 23:48
Location: Brasil

#3 Post by Jorgebrazil » 27 Jul 2005 01:57

Dear friend Andrew,

Thanks for your help. Yes "J" is address to write the data. Before to use a "J" as constant I tryed to use a number (ex. 20) and the problem occured again.

Thanks again,

Jorge

Storic
Posts: 393
Joined: 01 Oct 2004 00:20
Location: Australia (S.A.)

#4 Post by Storic » 27 Jul 2005 04:59

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

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;
}
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

Post Reply

Return to “mikroC General”