View previous topic :: View next topic |
Author |
Message |
wrsalasr
Joined: 09 Oct 2007 Posts: 4
|
How to write a Char constant in the EEPROM |
Posted: Mon Jun 22, 2009 9:09 am |
|
|
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
|
|
Posted: Mon Jun 22, 2009 9:26 am |
|
|
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
|
|
Posted: Mon Jun 22, 2009 9:47 am |
|
|
Hi, I am use the internal EEPROM of Pic16f877a |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Jun 22, 2009 9:51 am |
|
|
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
|
|
Posted: Mon Jun 22, 2009 10:28 am |
|
|
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
|
|
Posted: Mon Jun 22, 2009 11:20 am |
|
|
And what do you see on hyperterminal? Gibberish or nothing at all? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Jun 22, 2009 11:43 am |
|
|
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
|
|
Posted: Mon Jun 22, 2009 12:08 pm |
|
|
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); |
|
|
|
|