Dear all,
I have a S08PT60 and at the start of code, I disable the watchdog timer, but, after 6,2 ms the cpu reset.
I think that there is a error in my startup code . . . . but i don't find it !!
This is the my simple code:
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; export symbols
XDEF _Startup, main
; we export both '_Startup' and 'main' as symbols. Either can
; be referenced in the linker .prm file or from C/C++ later on
XREF __SEG_END_SSTACK ; symbol defined by the linker for the end of the stack
; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition
; code section
MyCode: SECTION
main:
_Startup:
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
ldhx #$C520
sthx WDOG_CNT ; First part of the WDG unlock sequence
ldhx #$D928
sthx WDOG_CNT ; Second part of the WDG unlock sequence
lda #$04
sta WDOG_TOVAL ; 4 ms di time out
lda #$01
sta WDOG_CS2
lda #$00
sta WDOG_CS1 ; Disable watchdog
lda #%00100000
sta PORT_PTCOE
lda PORT_PTCD
eor #$20
sta PORT_PTCD ; reset check
eor #$20
sta PORT_PTCD ; reset check
eor #$20
sta PORT_PTCD ; reset check
CLI ; enable interrupts
mainLoop:
; Insert your code here
NOP
BRA mainLoop
I have uset the PC5 for verify if the cpu reset, and it is reset every 6,2 ms
Please help me !!
Thanks
Stefano
Solved! Go to Solution.
Hi Stefano,
Having now looked at the PT60 reference manual I'd agree with you that the code is correct and within the stipulated timings. Of course one hopes that the code in the reference manual is correct in itself ;-) The only difference I can see between your code and Freescales is the following line:
WDOG_TOVAL = 1000; // setting timeout value
You're setting 4 hex and they 1000 decimal?
Ian
Ciao Stefano,
I haven't checked but it's possible that you are not using the correct watchdog timer unlock code(s), as I understand there can be different versions for each S08.
Ian
Unfortunately the code is correct !!
Hi Stefano,
Having now looked at the PT60 reference manual I'd agree with you that the code is correct and within the stipulated timings. Of course one hopes that the code in the reference manual is correct in itself ;-) The only difference I can see between your code and Freescales is the following line:
WDOG_TOVAL = 1000; // setting timeout value
You're setting 4 hex and they 1000 decimal?
Ian
Solved !!
The problem it isn't the value, but the dimension of WDOG_TOVAL, for takes effect it is necessary to write all register, and I wrote only the low of WDOG_TOVAL
Thanks for making me understand the differences and bringing me on the right track.
Stefano