View previous topic :: View next topic |
Author |
Message |
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
write_fix_value_external_eeprom |
Posted: Tue Jun 25, 2013 1:25 am |
|
|
Dear all.
I want to write fixed value into external eeprom when programing like command :
Code: | #rom int8 0xF00000={0,0} |
Can I do this work in CCS C?
my version : 4.140, PIC18F4680, external EEPROM : AT24C04 ( it work well with 2404.c driver of CCS C)
Pls show me way to fix it?
Thanks all. _________________ Begin Begin Begin !!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Jun 25, 2013 1:58 am |
|
|
Of course not.
The external EEPROM, is nothing to do with the PIC.
You need to program it with a hex file of it's own, and using a suitable programmer. |
|
|
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
|
Posted: Tue Jun 25, 2013 3:02 am |
|
|
thanks
It was solved by code, but when want to change fixed value, must change code and reprograming.
and here is my code:
1. to write fixed value into ext eeprom:
Code: |
write_ext_eeprom(0,1);
write_ext_eeprom(1,0);
write_ext_eeprom(2,0);
|
2. change code for the 2nd programing:
Code: |
write_offset=read_ext_eeprom(0);
printf("\n\r offset n\r", write_offset);
if(write_offset==0)
{
write_ext_eeprom(0,1);
write_ext_eeprom(1,0);
write_ext_eeprom(2,0);
}
else
{
output_low(PIN_C1);
output_low(PIN_C2);
delay_ms(500);
output_high(PIN_C1);
output_high(PIN_C2);
}
|
Thanks all _________________ Begin Begin Begin !!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Jun 25, 2013 4:00 am |
|
|
Seriously, use an array:
Code: |
const int8 eeprom_vals[]={1,0,0}
int count;
for (count=0;count<sizeof(eeprom_vals);count++)
write_ext_eeprom(count,eeprom_vals[count]);
|
|
|
|
|