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 CCS Technical Support

EEPROM Not erasing...

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



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

EEPROM Not erasing...
PostPosted: Thu Jan 03, 2008 10:14 pm     Reply with quote

Dear Sir,
here i am using 16f913, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534.

I am trying to erase the EEPROM If "RE3" held high.But it is not erasing the EEPROM.I toggle "RA0" in this loop the pin is toggling it means the control is comming inside the "if" loop but not erasing the EEPROM. I tried with "RB6" to held high then also EEPROM not erasing.Here is the part of my application
Code:
void main()
{
int32 stored_number;
int8 wr_rw_cycle;
int8 dec_number_address;
int8 read_erase;

int16 clear_ee = 0;
init_CPU();
wr_inc_dec_addr = 0;
stop_min_wr = 0;

/*
  for(clear_ee = 0; clear_ee<= 255;clear_ee++)
         write_eeprom(clear_ee,0);
*/
inc_min_address = read_eeprom(store_min_address);
dec_number_address = read_eeprom(store_number_address);

min_count = ee_read16((eeprom_minute_address + inc_min_address),2);      
number = ee_read32((eeprom_number_address - dec_number_address),4);
 
while(TRUE)
     {      
       printf(lcd_putc,"\f%7lu",number);
         if(INPUT_STATE(PIN_E3))
      {   
         for(clear_ee = 0; clear_ee<= 254;clear_ee++)
            {   
            
               read_erase = read_eeprom(clear_ee);
               if(read_erase != 0)
                  write_eeprom(clear_ee,0);
            }
               
               
            
      }
        
        if(min_count >= 360)//360   // if frequency is 297 Hz, min_count == 360, becomes after 6 min.
         {               // so number is incremented once after 6 min.
            
            number++;
            
            min_count = 0;
            if(number <= 255)
               wr_rw_cycle = 1;
            else if((number >255) &&(number < 65025))
               wr_rw_cycle = 2;
            else
               wr_rw_cycle = 3;
write_number_again:
            ee_write32((eeprom_number_address - dec_number_address), number,wr_rw_cycle); //write data to EEPROM loc 0x00
            stored_number = ee_read32((eeprom_number_address - dec_number_address),wr_rw_cycle);
            if(stored_number != number)
               {
                  dec_number_address++;   
                  wr_inc_dec_addr = 2;
                  if(dec_number_address == 150)
                     dec_number_address = 0;
                  goto write_number_again;
                }   
            no_freq = 0;   
            if(number == 999999)
               number = 0;            
         }
      switch(wr_inc_dec_addr)
               {
                  case 1 :  write_eeprom(store_min_address,inc_min_address);
                                  wr_inc_dec_addr = 0;
                          break;
                  case 2 : write_eeprom(store_number_address,dec_number_address);
                         wr_inc_dec_addr = 0;
                         break;   
               }
      
        }
     
}

i defined the ERASE statement(commented),before while(TRUE), it works fine and erasing the all locations,but in my application i have to erase EEPROM if RE3 held high
Quote:
/*
for(clear_ee = 0; clear_ee<= 255;clear_ee++)
write_eeprom(clear_ee,0);
*/

Plz help me to resolve my problem
_________________
Thank You,
With Best Regards,
Deepak.
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Sun Jan 06, 2008 3:39 am     Reply with quote

Try changing "if(INPUT_STATE(PIN_E3))" to "if(input(PIN_E3))".

Not sure if the TRIS will be set right with INPUT_STATE if you do not set it your self.

Have Fun

Mark
deepakomanna



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

EEPROM Not erasing...
PostPosted: Mon Jan 07, 2008 2:21 am     Reply with quote

I tried what you suggested,but still it is not working. The contol is comming inside the "IF" statement.I checked that with the debugger ICD2 basically i toggled one pin RA0 in this routine & checked on the oscilloscope.
My defined I/O are,
Code:
void  init_CPU()
{
//setup_lcd(LCD_DISABLED);   //VLCD pins used to supply LCD bias voltage are enabled on power-up (POR)
setup_oscillator(OSC_8MHZ | OSC_INTRC);
/**************  PORT SETTINGS ****************/
   PORT_B_PULLUPS(0X00);      // RB7 & RB6 i/p for programming devices.
   SET_TRIS_A(0XC0);         // i/p OSC1 & OSC2
   SET_TRIS_B(0X00);
   SET_TRIS_C(0X27);         //VLCD 1,2,3 i/p,FREQ i/p.
   SET_TRIS_E(0X08);         // RE3 i/p for RESETING the device EEPROM.
/*************** LCD SETTINGS ********************/
   SETUP_LCD( LCD_MUX14 |LCD_INTRC|VLCD_ENABLE, 2);   
/****************  COMPARATOR SETTINGS  ***************/
   SETUP_COMPARATOR(NC_NC_NC_NC);
/****************  INTERRUPT SETTINGS  *****************/
   ENABLE_INTERRUPTS(GLOBAL);
//   clear_interrupt(INT_TIMER1);
//   ENABLE_INTERRUPTS(INT_TIMER1);      //enable timer1 interrupt
   clear_interrupt(INT_TIMER0);
   ENABLE_INTERRUPTS(INT_TIMER0);      //enable timer1 interrupt
   
   SET_TIMER0(18);                     // timer0 interrupt for 30.464 msec.
                                 // 1 Count=128 Usec,So 256 - 238 ==18.
//   SETUP_TIMER_0(RTCC_EXTERNAL|RTCC_DIV_256);
      
set_timer1(0);           
setup_ccp1(CCP_CAPTURE_RE);       //Capture on rising edge
clear_interrupt(INT_CCP1);
enable_interrupts(INT_CCP1);
setup_timer_1(T1_EXTERNAL_SYNC|T1_DIV_BY_1|T1_CLK_OUT);
//setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1);


}
 

can anybody tell me solution. Confused
_________________
Thank You,
With Best Regards,
Deepak.
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Jan 09, 2008 1:16 pm     Reply with quote

Quote:
PORTE is a 1-bit, 4-bit or 8-bit port with Schmitt Trigger
input buffers. RE<7:4, 2:0> are individually configured as
inputs or outputs and RE3 is only available as an input if
MCLRE is ‘0’ in Configuration Word (Register 16-1).


Does this help?
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