|
|
View previous topic :: View next topic |
Author |
Message |
Storic
Joined: 03 Dec 2005 Posts: 182 Location: Australia SA
|
ICD_U40?? |
Posted: Wed Feb 08, 2006 5:16 am |
|
|
This is just a note;
I had a problem not with programming or even the code I was doing, for what ever reasion, the Micro was not getting programmed correctly.
I found that My PC had glitched internaly, Every was working OK, even the ICD_U40 was operating correctly with programming, just not able to program the micro corectly, (reboot the PC and every thing is now OK)
I was almost going to post this as a posible fault/bug?? a little bit of fault finding and all OK
Andrew _________________ What has been learnt if you make the same mistake? |
|
|
Storic
Joined: 03 Dec 2005 Posts: 182 Location: Australia SA
|
|
Posted: Wed Feb 08, 2006 4:26 pm |
|
|
It happened again and I found that it is related to the WDT, switch it off, works OK, switch it on again (Fault), it appears that the WDT is resetting to soon, I have the WDT set to 1:128 (2304ms) I am using timer 0 to reset the WDT and pole a CPU led at 1/2 sec intervals
Code: | /***********************************************************
* Timer 0 (RTCC) output, CPU led, Reset WDT *
***********************************************************/
#int_RTCC
RTCC_isr()
{
CPUled++; // Increment value of cnt on every interrupt
if (CPUled == 240) {
output_toggle(CPU_led);
CPUled = 0;
restart_wdt();
}
}
|
Code: | void Inilize()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_wdt(WDT_ON);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_bit);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
}
|
Code: | #FUSES WDT //Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
|
This only happens twice to 2 x boards. After doing some code manipulation, I got it to work OK, however when I put the original Code in that had this problem, It all works OK unable to refault. the micro is the 18F1320 and had been erased prior.
Should i have restart_wdt(); in the main program or is it OK where it is.
ANdrew _________________ What has been learnt if you make the same mistake? |
|
|
Guest
|
Don't use restart_wdt() in a timer int |
Posted: Fri Feb 10, 2006 7:58 am |
|
|
Sounds to me like a really bad idea to restart the WDT in a timer interrupt. One of the reasons for having a WDT is to come back if you get stuck in some bad code somewhere in your application.
If you restart the WDT in a timer intrerrupt, I se no reason at all to have WDT enabled.
// Magnus |
|
|
|
|
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
|