|
|
View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
EEPROM Not erasing... |
Posted: Thu Jan 03, 2008 10:14 pm |
|
|
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
|
|
Posted: Sun Jan 06, 2008 3:39 am |
|
|
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
|
EEPROM Not erasing... |
Posted: Mon Jan 07, 2008 2:21 am |
|
|
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. _________________ Thank You,
With Best Regards,
Deepak. |
|
|
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Wed Jan 09, 2008 1:16 pm |
|
|
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? |
|
|
|
|
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
|