 |
| Author |
Message |
|
|
Posted: Feb 15, 2012 - 02:55 PM |
|

Joined: Feb 24, 2011
Posts: 2
|
|
Hey guys,
I have a question.
I am trying to implement a watch dog timer with the example codes in AVR1310. But for some reason I cannot set de WDT.CTRL register. I can see that variable “temp” contains value 0x1F. Here is the code:
void WDT_EnableAndSetTimeout( WDT_PER_t period )
{
uint8_t temp = WDT_ENABLE_bm | WDT_CEN_bm | period;
CCP = CCP_IOREG_gc;
WDT.CTRL = temp;
/* Wait for WD to synchronize with new settings. */
while(WDT_IsSyncBusy()){
}
}
Any ideas?
Thanks in advance, Frank. |
|
|
| |
|
|
|
|
|
Posted: Feb 15, 2012 - 02:59 PM |
|


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway
|
|
What does the resulting assembly look like? You need to write to WDT.CTRL within 4 clock cycles of setting CCP, which that code will probably violate depending on the optimization settings selected and the exact code sequence generated by the compiler.
- Dean  |
_________________ Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
|
| |
|
|
|
|
|
Posted: Feb 15, 2012 - 03:45 PM |
|

Joined: Feb 24, 2011
Posts: 2
|
|
Hey Dean,
Thanks for your fast response!
You were right. The resulting assembly revealed that it took 5 clock cycles. After setting the optimization setting to “optimize most” it took only 2 cycles and the problem was solved!
Thanks a lot!
Cheers, Frank. |
|
|
| |
|
|
|
|
|
|
|