altron
Joined: 10 Mar 2008 Posts: 10
|
Posted: Thu Nov 19, 2020 1:26 am Post subject: Watchdog not stopping |
|
|
Hi
I had a problem with the Watchdog not stopping with the STOP WATCHDOG command with a XM128a1.
Example of not working.
Code: | Disable Jtag
$prog &HFF , &HFF , &H00 , &HFE , &H00 , &HFF , &HFB ' generated. Take care that the chip supports all fuse bytes.
$regfile = "xm128a1def.dat"
$crystal = 32000000 '32MHz
$hwstack = 128
$swstack = 128
$framesize = 128
Config Osc = Enabled , Pllosc = Disabled , Extosc = Disabled , 32khzosc = Disabled , 32mhzosc = Enabled , 32khzpowermode = Low_power '32MHz
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 '32MHz
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
Config Eeprom = Mapped
Active_led Alias Portf.5
Config Active_led = Output
Waitms 500
Active_led = 1 'led
Waitms 2000
Config Watchdog = 4000 'reconfig to 4 sec
Start Watchdog
Active_led = 0
Stop Watchdog '<<<<<<This dosent stop the watchdog
Active_led = 1
Do
Toggle Active_led
Waitms 100
Loop |
The watchdog takes sometime to sync with the system clock after being enabled. You need to wait till the SYNC bit is reset before stopping.
Example of working:
Code: | Disable Jtag
$prog &HFF , &HFF , &H00 , &HFE , &H00 , &HFF , &HFB ' generated. Take care that the chip supports all fuse bytes.
$regfile = "xm128a1def.dat"
$crystal = 32000000 '32MHz
$hwstack = 128
$swstack = 128
$framesize = 128
Config Osc = Enabled , Pllosc = Disabled , Extosc = Disabled , 32khzosc = Disabled , 32mhzosc = Enabled , 32khzpowermode = Low_power '32MHz
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 '32MHz
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
Config Eeprom = Mapped
Active_led Alias Portf.5
Config Active_led = Output
Waitms 500
Active_led = 1
Waitms 2000 'led
Config Watchdog = 4000 'reconfig to 2 sec
Start Watchdog
Active_led = 0
Gosub Stop_watchdog
Active_led = 1
Do
Toggle Active_led
Waitms 100
Loop
Stop_watchdog:
Do
If Wdt_status.0 = 0 Then
Exit Do
End If
Waitms 1
Loop 'Until Wdt_status.0 = 0
Stop Watchdog
Return |
(BASCOM-AVR version : 2.0.8.2 , Latest : 2.0.8.3 ) |
|