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

EEPROM losing data

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



Joined: 21 Feb 2006
Posts: 19
Location: San Diego

View user's profile Send private message

EEPROM losing data
PostPosted: Tue Dec 19, 2006 4:54 pm     Reply with quote

I have one of three systems that loses the data stored in it's eeprom when the power is cycled. Ttelmah talked about an over voltage condition on MCLR can cause this. I'm looking for more information...

Thanks,

Greg
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 5:08 pm     Reply with quote

Try to isolate the failure mechanism.

First thing, find out if it's occurring due to your writing of the eeprom.
Coment out the lines of code that write to the eeprom. Then run your
program and see if you still get the failure. (Initialize the eeprom to
some suitable value when you program the PIC with the ICD2).
Greg_R



Joined: 21 Feb 2006
Posts: 19
Location: San Diego

View user's profile Send private message

More details
PostPosted: Tue Dec 19, 2006 6:42 pm     Reply with quote

PIC18F8722 with 40MHz TTL Oscillator.
Linear Power Supply that has a clean, monotonic ramp. ~5.5ms to 5V.
MCLR is tied to VCC through a 47k resistor per CCS.
Compiler: 3.249
I was told the PIC was replaced but am not 100% certain of that.

I saw no problem with either MCLR or VCC while cycling power a number of times.

Steps:
Verified, using an ICD-U40, that the EEPROM was blank.
Ran the code to store the struct in EEPROM and stopped execution.
Verified that the values had been written.
Started excecution.
Cycled the power.
Checked the EEPROM and it was once again blank.

Greg
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 7:13 pm     Reply with quote

I have these questions:

1. Was this recent test done while the PIC is being controlled by the
CCS ICD-U40 debugger ? Or was it run in stand-alone mode ?

2. When you did the test, was it done with the changes made that
I suggested in my post ?

In my post, I suggested that you should comment out all lines of
code that write to the internal eeprom. Example:
Code:
// write_eeprom(addr, data);

I also suggested that you preset the internal EEPROM values, so that
they are programmed when the PIC is programmed, and at no other
time. Example:
Code:
#rom int 0xF00000={1,2,3,4}

Also, your tests should be done completely in stand-alone mode.
The debugger should not be attached to the board.
Greg_R



Joined: 21 Feb 2006
Posts: 19
Location: San Diego

View user's profile Send private message

The saga continues
PostPosted: Wed Dec 20, 2006 7:38 pm     Reply with quote

I attempted to use the #rom as suggested and it fails to program on the three systems I tried it on. The following compiles fine but fails the verification step of programming with an ICD-U40.

Code:

#include <18F8722.h>
#device *=16
#device adc=8

#FUSES NOWDT, WDT128, EC_IO, NOPROTECT, IESO, BROWNOUT, BORV25, PUT, NOCPD
#FUSES STVREN, NODEBUG, NOLVP, NOWRT, NOCPB, NOEBTRB, NOEBTR, NOWRTD, NOWRTC
#FUSES NOWRTB, FCMEN, LPT1OSC, MCLR, NOXINST, MCU

#use delay(clock=40000000)

#use rs232( stream = PC, baud=115200, parity=N, xmit=PIN_G1, rcv=PIN_G2, errors )

#define RLED             PIN_F7
#define YLED             PIN_H5

#rom int8 0xF0000 = { 1, 2, 3, 4 }

void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(VREF_LOW|-2);
   setup_low_volt_detect(FALSE);
   setup_oscillator(False);

   output_low( RLED ) ;
   output_high( YLED ) ;
   delay_ms( 350 ) ;

   output_high( RLED ) ;
   output_low( YLED ) ;
   delay_ms( 350 ) ;

   output_low( RLED ) ;

   while( 1 )
   {
      if( read_eeprom( 0x0000 ) == 1 )
         output_high( YLED ) ;
      else
         output_high( RLED ) ;

      delay_ms( 100 ) ;

      output_low( YLED ) ;
      output_low( RLED ) ;
      delay_ms( 100 ) ;
   }

}


Any ideas what my stupid mistake is???
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 20, 2006 7:54 pm     Reply with quote

Count the number of zeros in your eeprom address, compared to my
sample code.
Greg_R



Joined: 21 Feb 2006
Posts: 19
Location: San Diego

View user's profile Send private message

Hitting the PostReply seems to high light stupid mistakes...
PostPosted: Wed Dec 20, 2006 8:01 pm     Reply with quote

The #rom should be:
#rom int8 0xF00000 = { 1, 2, 3, 4 }
not:
#rom int8 0xF0000 = { 1, 2, 3, 4 }

Couldn't see it for two hours but post it...

It works. Back to the hole.
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