View previous topic :: View next topic |
Author |
Message |
Guest
|
Problem with external EEPROM |
Posted: Wed Feb 25, 2004 8:08 am |
|
|
Code: |
#include "C:\WINDOWS\Bureau\youpi\youpi.h"
#include "24lc256.c"
void main() {
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
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);
set_tris_E(0x00);
init_ext_eeprom();
write_ext_eeprom(0x00,'A',EEPROM1);
do
{
output_high(pin_E0);
output_high(pin_E1);
output_high(pin_E2);
delay_ms(5000);
output_low(pin_E0);
output_low(pin_E1);
output_low(pin_E2);
delay_ms(5000);
}
while(1);
}
|
when i use this line: write_ext_eeprom(0x00,'A',EEPROM1);
My pic 16F877 freeze. When i put this line in comment, all port works fine.
Helpppppp me pleaseeeee!!! |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Wed Feb 25, 2004 8:46 am |
|
|
Just a guess but I think your watchdog timeout is too short for the eeprom write duration. The PIC is resetting due to the WDT timeout. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Guest
|
hmmm |
Posted: Wed Feb 25, 2004 8:52 am |
|
|
I don't use watch dog timer |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Wed Feb 25, 2004 10:08 am |
|
|
If you are not using the watchdog then why do you have this line?
Code: | setup_counters(RTCC_INTERNAL,WDT_18MS); |
That is configuring the watchdog for an 18ms (approximately) timeout.
There have been so many errors with the way the #FUSE statement is compiled that you may actually be enabling the WDT without knowing it.
Just for the heck of it, change WDT_18MS to WDT_2304MS and see if it still "locks" up.
Also you can check for the reset by toggling a single ouput line before you call your eeprom write routine. If it only toggles once then you are probably not resetting. But if it toggles every 18ms then you are resetting due to your WDT value. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|