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

Problem with external EEPROM

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








Problem with external EEPROM
PostPosted: Wed Feb 25, 2004 8:08 am     Reply with quote

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

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

PostPosted: Wed Feb 25, 2004 8:46 am     Reply with quote

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
PostPosted: Wed Feb 25, 2004 8:52 am     Reply with quote

I don't use watch dog timer
rwyoung



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

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

PostPosted: Wed Feb 25, 2004 10:08 am     Reply with quote

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!
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