Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Atmel 89c52 interfacing with AT24c512 EEPROM

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,492
I WANT TO KNOW THAT I WROTE A CODE SAVING COUNTER VALUES IN EEPROM AT24c512 BUT PROBLEM IS THAT I COULD NOT ABLE TO STORE VALUE ABOVE 255, I WANT TO STORE VALUE 0-500.

PLEASE LET ME KNOW HOW TO DO?


Code:
void ex0_isr (void) interrupt 0
{
ex0_isr_counter++;   // Increment the count by button
}

void main()
{
ex0_isr_counter = read_byte_from_eeprom(0);

while(1)
{
write_byte_to_eeprom(0 , ex0_isr_counter);	
display(ex0_isr_counter);	
}
}
 

Hi,

For sure you know that one byte has a limited range of 0...255 (unsigned).
This really is very basic knowledge.

--> use two or more bytes.

Klaus
 
Yes I know, counter value increases 0 to 500 when reaches 255 it got stored but above values are not storing?

I want to know how store values above 255?
 

Your

Code:
ex0_isr_counter

should be of int type

and the new code should be

Code:
write_byte_to_eeprom(0 , (ex0_isr_counter & 0xFF));
write_byte_to_eeprom(1 , ((ex0_isr_counter & 0xFF00) >> 8));	
display(ex0_isr_counter);
 
Yes it is already integer type but you provide best solution.Its great, you are good.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top