CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to write a Char constant in the EEPROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wrsalasr



Joined: 09 Oct 2007
Posts: 4

View user's profile Send private message

How to write a Char constant in the EEPROM
PostPosted: Mon Jun 22, 2009 9:09 am     Reply with quote

Hi, I want to write a char constant name[] in the eeprom. How I can do it?? In this way does not work:
Code:

int i = 0;

char name[] = "Flux-564330";

void main() {

     for (i = 0; i < 12; i++){
          write_eeprom(i, name[i]);
          }

}


Last edited by wrsalasr on Mon Jun 22, 2009 9:44 am; edited 1 time in total
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 22, 2009 9:26 am     Reply with quote

Are you using the internal EEPROM? WHich device are you using?
The CCS supported command is write_eeprom().
wrsalasr



Joined: 09 Oct 2007
Posts: 4

View user's profile Send private message

PostPosted: Mon Jun 22, 2009 9:47 am     Reply with quote

Hi, I am use the internal EEPROM of Pic16f877a
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 22, 2009 9:51 am     Reply with quote

When you say it does not work, how do you know. Did you try reading the eeprom and sending the output to hyperterminal to see what the values are?

Also can you post your complet C program?
wrsalasr



Joined: 09 Oct 2007
Posts: 4

View user's profile Send private message

PostPosted: Mon Jun 22, 2009 10:28 am     Reply with quote

I am use the hiperterminal to check the read, here is my code:

Code:
#include <16f877a.h>                         
#fuses XT,NOWDT,NOPROTECT,NOLVP,PUT,BROWNOUT
#use delay(clock=20M)                     
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

int i = 0;

char name[] = "Flux-564330";


void main() {

     for (i = 0; i < 12; i++){
          write_eeprom(i, name);
          }
       
     delay_ms(200);
     for (i = 0; i < 12; i++){
          printf ("%c",read_eeprom(i));
          }
       
}
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 22, 2009 11:20 am     Reply with quote

And what do you see on hyperterminal? Gibberish or nothing at all?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 22, 2009 11:38 am     Reply with quote

See this thread which shows different ways to write data to eeprom:
http://www.ccsinfo.com/forum/viewtopic.php?t=32722
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jun 22, 2009 11:43 am     Reply with quote

Which code did you use? The first should work, the second can't.

In addition, using a 20 MHz crystal in XT mode shouldn't be expected to work.
Guest








PostPosted: Mon Jun 22, 2009 12:08 pm     Reply with quote

problem solved !!!
Here is the code:

Code:
#include <16f877a.h>                         
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT,BROWNOUT
#use delay(clock=20000000)                     
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

int i = 0;

char name[] = "Flux-564330";


void main() {

     for (i = 0; i < 12; i++){
          write_eeprom(i, name[i] );
          }
       
     delay_ms(200);
     for (i = 0; i < 12; i++){
          printf ("%c",read_eeprom(i));
          }
         
   while(1);
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group