Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Watchdog in CodevisionAVR

Status
Not open for further replies.

ns2014

Newbie level 2
Joined
Jun 27, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Dear All,
I'm looking for an example for using the Watchdog timer in Codevision but I cannot find any.
I used the Wizard to generate the code to include the Watchdog timer
Code:
// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

but I was expecting some straightforward functions such as:
watchdog_enable() //to reset and start the timer
watchdog_disable()// to stop the timer

I couldn't find any example.
I'm also puzzled with the code above:
CLKPR=0x80;
CLKPR=0x00;
how come it is overwriting the same flag? it is new to me:)
Thanks
 

How about cheching the AVR datasheet for the purpose of the consequent writes to the CLKPR register?
 

Thanks for the pointer. I just checked the datasheet and realized that they are using the sequence purposefully.

To elaborate more on my example request:
I'm using USART to communicate between two MCUs. I'm using getchar() to receive the data. sometimes one unit hangs, so the other keeps waiting indefinitely for the data.
I want to use the watchdog timer to ensure if the communication is not received within x ms, I reset the units. and start over.
I'm expecting the code flow as:
//start the timer
enable_wdt();
get_char()
disable_wdt()

so if disable_wdt is reached this means getchar() received the byte and then the watchdog timer is disabled and the code continue the execution normally. but if get_char() hangs then I restart the unit.
thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top