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

16F818, ccs printf function allows WDT timeout

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



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

16F818, ccs printf function allows WDT timeout
PostPosted: Fri Jan 01, 2010 11:27 pm     Reply with quote

Using a 16F818 I find that printing data on a port pin B7 allows the WDT to timeout and reset the uP. I use the maximum allowed WDT value and restart the timer before the printf function call.
How can I get this to work?
Jim
_________________
Jim Oram
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 01, 2010 11:31 pm     Reply with quote

Post a very short, compilable program that shows the problem,
and post your compiler version.
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

PostPosted: Fri Jan 01, 2010 11:49 pm     Reply with quote

The compiler version is CCS PCM Version 3.223, 28923

I will post the simplified compilable program tomorrow.

Thanks,
_________________
Jim Oram
Ttelmah
Guest







PostPosted: Sat Jan 02, 2010 3:48 am     Reply with quote

Are you using Timer0?.
The watchdog postscaler, is 'shared' as the Timer0 prescaler. If you have a timer0 configuration, which selects a faster prescaler, this overrides the watchdog setting.
Obviously, the time taken by a printf, will depend on your UART speed, and the length of the string. If the watchdog postscaler is being set to '1', by a timer setup, then a 9600bps, it'll time out after only about 15 characters....

Best Wishes
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

PostPosted: Sat Jan 02, 2010 6:53 am     Reply with quote

Yes I am using timer0.
Should I use timer1? How can I use timer1 for the 'use rs232' , or
shift my main timer for system timing to timer1?

Thanks,
_________________
Jim Oram
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

16F818, ccs printf function allows WDT timeout
PostPosted: Sat Jan 02, 2010 7:50 am     Reply with quote

A side Question, does the 16F818 have the ANSEL register?

Thanks,
_________________
Jim Oram
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

PostPosted: Sat Jan 02, 2010 8:13 am     Reply with quote

I moved the main timing to timer1, taking it out of timer0 routine.
Enabling timer1 interrupt it works and timing is ok, but enabling the wdt it still restarts the system.... I am using a baud rate of 1200 on B7.
Your input would be most appreciated.
Thanks,
_________________
Jim Oram
Ttelmah
Guest







PostPosted: Sat Jan 02, 2010 8:20 am     Reply with quote

#use RS232, does not use the timers at all.

You can use timer0, but not the prescaler. Look at the data sheet. Section 6.4. The 'point' is if you select any of the 'RTCC_DIV' options in CCS, except RTCC_DIV_1, it overrides the prescaler, and assigns it to timer0.

You have timer1, and timer2 available without this restriction.

Best Wishes
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

PostPosted: Sat Jan 02, 2010 8:28 am     Reply with quote

Thanks for the point, so if I use a wdt time out of WDT_2304MS, (I am using the 818 internal clk at ~4mhz) , not sure if 1200 baud with a 6 char string will be within range. Figuring 8ms per bit, with 48 plus start stop will still allow the wdt to kick. Shocked
Thanks,
_________________
Jim Oram
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

16F818, ccs printf function allows WDT timeout
PostPosted: Sat Jan 02, 2010 10:44 am     Reply with quote

Got the printf working with the WDT but the format:
printf("Value is %2d\n", pot_timer_value);
gives an error - printf format type is invalid -

However it -does- work with:

printf("Value is %2X\n", pot_timer_value);

Why does the %2d not work?

Thanks,
_________________
Jim Oram
Ttelmah
Guest







PostPosted: Sat Jan 02, 2010 11:02 am     Reply with quote

What is 'pot_timer_value' declared as?.
int, signed, int16 etc...


Best Wishes
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

16F818, ccs printf function allows WDT timeout
PostPosted: Sat Jan 02, 2010 11:38 am     Reply with quote

printf problem... fixed by using:
printf("Value is %2LD\n", pot_timer_value);
Thanks,
_________________
Jim Oram
Jim Oram



Joined: 01 Jan 2010
Posts: 24
Location: Charlotte

View user's profile Send private message

16F818, ccs printf function allows WDT timeout
PostPosted: Sat Jan 02, 2010 3:05 pm     Reply with quote

Thanks for your help,
I don't know what I would do without you guys.
I seem to have these brain meltdowns lately,
probably too much sugar from my wife's 7 layer cookies.
Thanks, Rolling Eyes
_________________
Jim Oram
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