+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Advanced Member level 2
    Points: 4,016, Level: 14
    Achievements:
    7 years registered
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    650
    Helped
    3 / 3
    Points
    4,016
    Level
    14

    Atmel 89c52 interfacing with AT24c512 EEPROM

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

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 81,871, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,624
    Helped
    3763 / 3763
    Points
    81,871
    Level
    69

    Re: Atmel 89c52 interfacing with AT24c512 EEPROM

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 2
    Points: 4,016, Level: 14
    Achievements:
    7 years registered
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    650
    Helped
    3 / 3
    Points
    4,016
    Level
    14

    Re: Atmel 89c52 interfacing with AT24c512 EEPROM

    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?
    IMRAN



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 3
    Points: 3,642, Level: 14
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    728
    Helped
    54 / 54
    Points
    3,642
    Level
    14

    Re: Atmel 89c52 interfacing with AT24c512 EEPROM

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


    1 members found this post helpful.

  5. #5
    Advanced Member level 2
    Points: 4,016, Level: 14
    Achievements:
    7 years registered
    imranahmed's Avatar
    Join Date
    Dec 2011
    Location
    Karachi,Pakistan
    Posts
    650
    Helped
    3 / 3
    Points
    4,016
    Level
    14

    Re: Atmel 89c52 interfacing with AT24c512 EEPROM

    Yes it is already integer type but you provide best solution.Its great, you are good.
    IMRAN



--[[ ]]--