View previous topic :: View next topic |
Author |
Message |
Jim Oram
Joined: 01 Jan 2010 Posts: 24 Location: Charlotte
|
16F818, ccs printf function allows WDT timeout |
Posted: Fri Jan 01, 2010 11:27 pm |
|
|
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
|
|
Posted: Fri Jan 01, 2010 11:31 pm |
|
|
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
|
|
Posted: Fri Jan 01, 2010 11:49 pm |
|
|
The compiler version is CCS PCM Version 3.223, 28923
I will post the simplified compilable program tomorrow.
Thanks, _________________ Jim Oram |
|
|
Ttelmah Guest
|
|
Posted: Sat Jan 02, 2010 3:48 am |
|
|
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
|
|
Posted: Sat Jan 02, 2010 6:53 am |
|
|
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
|
16F818, ccs printf function allows WDT timeout |
Posted: Sat Jan 02, 2010 7:50 am |
|
|
A side Question, does the 16F818 have the ANSEL register?
Thanks, _________________ Jim Oram |
|
|
Jim Oram
Joined: 01 Jan 2010 Posts: 24 Location: Charlotte
|
|
Posted: Sat Jan 02, 2010 8:13 am |
|
|
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
|
|
Posted: Sat Jan 02, 2010 8:20 am |
|
|
#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
|
|
Posted: Sat Jan 02, 2010 8:28 am |
|
|
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.
Thanks, _________________ Jim Oram |
|
|
Jim Oram
Joined: 01 Jan 2010 Posts: 24 Location: Charlotte
|
16F818, ccs printf function allows WDT timeout |
Posted: Sat Jan 02, 2010 10:44 am |
|
|
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
|
|
Posted: Sat Jan 02, 2010 11:02 am |
|
|
What is 'pot_timer_value' declared as?.
int, signed, int16 etc...
Best Wishes |
|
|
Jim Oram
Joined: 01 Jan 2010 Posts: 24 Location: Charlotte
|
16F818, ccs printf function allows WDT timeout |
Posted: Sat Jan 02, 2010 11:38 am |
|
|
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
|
16F818, ccs printf function allows WDT timeout |
Posted: Sat Jan 02, 2010 3:05 pm |
|
|
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, _________________ Jim Oram |
|
|
|