Jump to content
Sign in to follow this  
bhPIC

Writing / Reading EEPROM with C2C Compilier

Recommended Posts

I am having a hard time writing to the EEPROM on my PIC16F877. I am using the EEPROM functions which are in the piccode.c file included in the project.

I have gone to a main() that just writes to the eeprom and then reads and prints to my lcd. The lcd works great, for instance if I just say wrt_lcd(‘A’); then I get the A on the screen. However, I seem to be getting garbage out of the eeprom read function.

 

Help!!

 

 

char a,b,d;

void main()

{           asm{

                       clrf        PORTD

                       bsf        STATUS,RP0

                       movlw   b'00000000'

                       movwf   PORTD

                       movlw   b'00111111'

                       movwf   PORTA

                       movlw   b'00000111'       ;digital i/o on porta

                       movwf   ADCON1

                       movlw   b'00000000'

                       movwf   PORTB

                       bcf        STATUS,RP0    

                       clrf        PORTB

                       clrf        PORTA }

            lcd_init();

 

ret_main:

           clear_LCD();

           line1();

           _EEPROMWrite(0x01, 'a');  

           delay_s(1);

           _EEPROMWrite(0x02, 'b');

           delay_s(1);

           _EEPROMWrite(0x03, 'c');  

           delay_s(1);

           line2();

           a = _EEPROMRead(0x01);

           b = _EEPROMRead(0x02);

           d = _EEPROMRead(0x03);

           wrt_lcd(a);wrt_lcd(B);wrt_lcd(d);

           delay_s(2);

           goto ret_main;

 

}

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...