![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Zachr
Joined: 12 Mar 2010 Posts: 10
|
18f23k22, using internal clock, timing issue |
Posted: Sun Feb 13, 2011 11:33 am |
|
|
This is the first time I have used a 'K' family of pic. Trying to do a hello-world blink and LED. If I download the following:
Code: |
#include <18F23K22.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC //Internal RC Osc
#FUSES NOPLLEN
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOLPT1OSC //Timer1 configured for higher power operation
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(int=16000000)
void main()
{
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_4(T4_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
while(1)
{
output_high(pin_c0);
delay_ms(1000);
output_low(pin_c0);
delay_ms(1000);
}
} |
and run it, C0 stays high. If I run the same code, but start it from the debugger, I get C0 toggling once a second like it should. If I reduce the delay from 1000ms down to 100ms, it works with or without the debugger. If I do this:
Code: |
while(1)
{
output_high(pin_c0);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
output_low(pin_c0);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
}
|
...it fails unless started in the debugger. Seems like a clock config issue, but nothing I try seems to make a difference. Thoughts? Suggestions?
Thanks,
Zach |
|
![](templates/subSilver/images/spacer.gif) |
Zachr
Joined: 12 Mar 2010 Posts: 10
|
|
Posted: Sun Feb 13, 2011 1:18 pm |
|
|
Should have mentioned using I'm using 4.119
-Zach |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 13, 2011 2:18 pm |
|
|
Try a more simple program:
Code: |
#include <18F23K22.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=16M)
//======================================
void main(void)
{
while(1)
{
output_high(PIN_C0);
delay_ms(1000);
output_low(PIN_C0);
delay_ms(1000);
}
} |
I tested this in hardware for an 18F45K22 and it worked. I ran it in
standalone (not debugger) mode. This was with vs. 4.119. |
|
![](templates/subSilver/images/spacer.gif) |
Zachr
Joined: 12 Mar 2010 Posts: 10
|
|
Posted: Sun Feb 13, 2011 2:34 pm |
|
|
Thanks! That helped me figure it out. The issue is that the even though I was using the NOWDT fuse, if the WDT128 fuse is in there, the watchdog starts up.
The PIC wizard adds the WDT128 fuse even if you say you don't want to use the watchdog timer. Seems to be a bug. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|