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

write / read eeprom -- integers
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guestt
Guest







write / read eeprom -- integers
PostPosted: Sat Mar 05, 2005 11:45 am     Reply with quote

Im using 16F877 and if i write values form 0 to 10 all is working ok.
If i want to write value 240 i get blocked program...

How can i write and read bigger int data to eeprom?



John
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Sat Mar 05, 2005 12:01 pm     Reply with quote

Post smallest possible sample program that exhibits the problem. Also include the compiler version number and programmer type.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Guestt
Guest







PostPosted: Sun Mar 06, 2005 4:19 am     Reply with quote

Code:

#define adr_bPress  0xF000   

....
main()
write_eeprom(adr_bPress,00);

if(bPress())
{
   lcd_gotoxy(1,1);
                    value++;
   write_eeprom(adr_bPress,value);
                    printf(lcd_putc,"%X",value);
 
}


Im trying to count from 1 to 240... First 10 numbers are displayed OK but after that nothing happens.

2.)
How can i read stored eeprom values thet are in range from 0xF000
to 0xF00A ?
Guesst
Guest







PostPosted: Sun Mar 06, 2005 4:25 am     Reply with quote

....
compiler version is 3.150 and programmer is ICD2..
Guest








PostPosted: Sun Mar 06, 2005 6:33 am     Reply with quote

With this code, you will wear out the EEPROM very fast!

Take care and write data only when needed.
Guest
Guest







PostPosted: Sun Mar 06, 2005 7:40 am     Reply with quote

... any suggestions or example code how to make this on correct way?
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Sun Mar 06, 2005 8:48 am     Reply with quote

Forgetting for a moment that you are going to wear-out the EEPROM quickly with your code, I can't tell much from what you posted. I should have been more explicit and said the SMALLEST POSSIBLE COMPLETE PROGRAM.

Given the age of your compiler I'd suspect it isn't doing the internal eeprom write correctly. Look at the LST file and compare the code associated with "write_eeprom" with the datasheet for your part. There will be a section in the datasheet that discusses the internal EEPROM and the correct way to write. And depending on your exact part, you may also need to check the errata.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Sun Mar 06, 2005 9:11 am     Reply with quote

From what he posted, he is not able to get the printf command to work correctly. He doesn't even read the eeprom values.
Guestt
Guest







PostPosted: Mon Mar 07, 2005 12:26 pm     Reply with quote

Code:
#include <16F877.h>
#include <lcd.c>
#device adc=8
#use delay(clock=20000000)
#fuses HS,WDT
#define adr_bPress 0x00


void main()
{

   lcd_init();
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters(RTCC_INTERNAL,WDT_18MS);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);

 
   
   write_eeprom(adr_bPress,00);
   if(INPUT(PIN_B0))
   {
      //lcd_gotoxy(1,1);
      value++;
      write_eeprom(adr_bPress,value);
      printf(lcd_putc,"%X",read_eeprom(adr_bPress));
   }
}


/// ---- this is what im using BUT ich need some new(better) way to to this. Can you give me some eg. from 1 to 500 ?


Manfred
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Mar 07, 2005 2:53 pm     Reply with quote

You are telling us you want to have an improved version of the shown code, but which part exactly do you need improvement on? It looks fine to me, so what is the reason you want suggestions for improvement?

The only problem I can think of is that the eeprom is specified to a minimum of 100.000 write cycles, say 10.000 to be on the safe side. How often is your program going to write to the eeprom?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 07, 2005 3:19 pm     Reply with quote

Quote:

#define adr_bPress 0xF000
write_eeprom(adr_bPress,00);

This can't work. The 16F877 only has 256 bytes of internal eeprom.
The address range is 0x00 to 0xFF. You are trying to write to
an eeprom address that does not exist.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Mar 07, 2005 3:29 pm     Reply with quote

PCM programmer wrote:
Quote:

#define adr_bPress 0xF000
write_eeprom(adr_bPress,00);

This can't work. The 16F877 only has 256 bytes of internal eeprom.
The address range is 0x00 to 0xFF. You are trying to write to
an eeprom address that does not exist.


Not to mention that he never increments the address if is actually trying to.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Mar 07, 2005 3:32 pm     Reply with quote

Also read this but I think maybe his compiler is too old for it to affect him
http://www.ccsinfo.com/forum/viewtopic.php?t=21281&highlight=printf+glue
Guest
Guest







PostPosted: Sun Mar 27, 2005 7:12 am     Reply with quote

Can someone post another "universal" ( for different chips) working example for this task ?

Thank you in advance
Guest
Guest







PostPosted: Sun Mar 27, 2005 7:45 am     Reply with quote

.... forgot to mention, im counting this and i overwrite last value with the new one.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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