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 CCS Technical Support

wdt problem from sleep

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







wdt problem from sleep
PostPosted: Thu Nov 14, 2002 2:33 pm     Reply with quote

Hi,

I'm using timer2 on a 16f628 to transmit data at a given rate for given time period. However I need the PIC to go to sleep in between data burst. Unfortunately i can't seem to wake the PIC up again using the WDT when its a sleep. It seems to work ok when I don't have it in sleep mode or use a wdt.

I've listed the basics of the programs below and how i set most the things up. I also make sure that I have restart the wdt before it times_out and resets.





Cut down version of program

#include "16F628.h"
#fuses XT,WDT,NOPROTECT
#use Delay (clock=4000000)

#int_timer2

/*interrupt handler */
handler() {
restart_wdt();
do other stuff...

}


void main(void) {

set_tris_a(0xFF) ; /*set all port a for input*/
set_tris_b(0x00) ; /*set all port b for output*/

setup_timer_2(T2_DIV_BY_1,128,2);
setup_wdt(WDT_18MS);

enable_interrupts(INT_TIMER2) ;
enable_interrupts(GLOBAL) ;


while(1) {

restart_wdt();
sleep();

do stuff.......using inturrupt handler for given
time period..when finished go back to sleep.

}
}


Any help much appreciated..


Steve
___________________________
This message was ported from CCS's old forum
Original Post ID: 8939
Tomi
Guest







Re: wdt problem from sleep
PostPosted: Fri Nov 15, 2002 2:17 am     Reply with quote

Clock is off under sleep so Timer2 never incremented under sleep. Use Timer1 with external 32768 Hz xtal and use Timer1 interrupt for both wakeup and timing the transmit.

:=Hi,
:=
:=I'm using timer2 on a 16f628 to transmit data at a given rate for given time period. However I need the PIC to go to sleep in between data burst. Unfortunately i can't seem to wake the PIC up again using the WDT when its a sleep. It seems to work ok when I don't have it in sleep mode or use a wdt.
:=
:=I've listed the basics of the programs below and how i set most the things up. I also make sure that I have restart the wdt before it times_out and resets.
:=
:=
:=
:=
:=
:=Cut down version of program
:=
:=#include "16F628.h"
:=#fuses XT,WDT,NOPROTECT
:=#use Delay (clock=4000000)
:=
:=#int_timer2
:=
:=/*interrupt handler */
:=handler() {
:= restart_wdt();
:= do other stuff...
:=
:=}
:=
:=
:=void main(void) {
:=
:= set_tris_a(0xFF) ; /*set all port a for input*/
:= set_tris_b(0x00) ; /*set all port b for output*/
:=
:= setup_timer_2(T2_DIV_BY_1,128,2);
:= setup_wdt(WDT_18MS);
:=
:= enable_interrupts(INT_TIMER2) ;
:= enable_interrupts(GLOBAL) ;
:=
:=
:= while(1) {
:=
:= restart_wdt();
:= sleep();
:=
:= do stuff.......using inturrupt handler for given
:= time period..when finished go back to sleep.
:=
:= }
:=}
:=
:=
:=Any help much appreciated..
:=
:=
:=Steve
___________________________
This message was ported from CCS's old forum
Original Post ID: 8958
Steveny
Guest







Re: wdt problem from sleep
PostPosted: Fri Nov 15, 2002 5:18 am     Reply with quote

I've fixed the problem now by using

setup_counters(RTCC_INTERNAL, WDT_2304MS);

the first timer0 as the wdt. However there is an error in the code below in which I forgot to put a delay instruction to allow the interrupt to happen a number of times before it went back to sleep. So the pic woke up checked somthing and went back to sleep before the interrupt had time to transmit data. DOH!!!







:=Clock is off under sleep so Timer2 never incremented under sleep. Use Timer1 with external 32768 Hz xtal and use Timer1 interrupt for both wakeup and timing the transmit.
:=
:=:=Hi,
:=:=
:=:=I'm using timer2 on a 16f628 to transmit data at a given rate for given time period. However I need the PIC to go to sleep in between data burst. Unfortunately i can't seem to wake the PIC up again using the WDT when its a sleep. It seems to work ok when I don't have it in sleep mode or use a wdt.
:=:=
:=:=I've listed the basics of the programs below and how i set most the things up. I also make sure that I have restart the wdt before it times_out and resets.
:=:=
:=:=
:=:=
:=:=
:=:=
:=:=Cut down version of program
:=:=
:=:=#include "16F628.h"
:=:=#fuses XT,WDT,NOPROTECT
:=:=#use Delay (clock=4000000)
:=:=
:=:=#int_timer2
:=:=
:=:=/*interrupt handler */
:=:=handler() {
:=:= restart_wdt();
:=:= do other stuff...
:=:=
:=:=}
:=:=
:=:=
:=:=void main(void) {
:=:=
:=:= set_tris_a(0xFF) ; /*set all port a for input*/
:=:= set_tris_b(0x00) ; /*set all port b for output*/
:=:=
:=:= setup_timer_2(T2_DIV_BY_1,128,2);
:=:= setup_wdt(WDT_18MS);
:=:=
:=:= enable_interrupts(INT_TIMER2) ;
:=:= enable_interrupts(GLOBAL) ;
:=:=
:=:=
:=:= while(1) {
:=:=
:=:= restart_wdt();
:=:= sleep();
:=:=
:=:= do stuff.......using inturrupt handler for given
:=:= time period..when finished go back to sleep.
:=:=
:=:= }
:=:=}
:=:=
:=:=
:=:=Any help much appreciated..
:=:=
:=:=
:=:=Steve
___________________________
This message was ported from CCS's old forum
Original Post ID: 8969
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