/*===========================================================================*/
|
/*===========================================================================*/
|
/* Copyright (C) 2001 Authors */
|
/* Copyright (C) 2001 Authors */
|
/* */
|
/* */
|
/* This source file may be used and distributed without restriction provided */
|
/* This source file may be used and distributed without restriction provided */
|
/* that this copyright statement is not removed from the file and that any */
|
/* that this copyright statement is not removed from the file and that any */
|
/* derivative work contains the original copyright notice and the associated */
|
/* derivative work contains the original copyright notice and the associated */
|
/* disclaimer. */
|
/* disclaimer. */
|
/* */
|
/* */
|
/* This source file is free software; you can redistribute it and/or modify */
|
/* This source file is free software; you can redistribute it and/or modify */
|
/* it under the terms of the GNU Lesser General Public License as published */
|
/* it under the terms of the GNU Lesser General Public License as published */
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
/* */
|
/* */
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
/* License for more details. */
|
/* License for more details. */
|
/* */
|
/* */
|
/* You should have received a copy of the GNU Lesser General Public License */
|
/* You should have received a copy of the GNU Lesser General Public License */
|
/* along with this source; if not, write to the Free Software Foundation, */
|
/* along with this source; if not, write to the Free Software Foundation, */
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* */
|
/* */
|
/*===========================================================================*/
|
/*===========================================================================*/
|
/* WATCHDOG TIMER */
|
/* WATCHDOG TIMER */
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/* Test the Watdog timer: */
|
/* Test the Watdog timer: */
|
/* - Interval timer mode. */
|
/* - Interval timer mode. */
|
/* */
|
/* */
|
/* Author(s): */
|
/* Author(s): */
|
/* - Olivier Girard, olgirard@gmail.com */
|
/* - Olivier Girard, olgirard@gmail.com */
|
/* */
|
/* */
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/* $Rev: 111 $ */
|
/* $Rev: 134 $ */
|
/* $LastChangedBy: olivier.girard $ */
|
/* $LastChangedBy: olivier.girard $ */
|
/* $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $ */
|
/* $LastChangedDate: 2012-03-22 21:31:06 +0100 (Thu, 22 Mar 2012) $ */
|
/*===========================================================================*/
|
/*===========================================================================*/
|
|
|
.global main
|
.global main
|
|
|
.set DMEM_BASE, (__data_start )
|
.set DMEM_BASE, (__data_start )
|
.set DMEM_200, (__data_start+0x00)
|
.set DMEM_200, (__data_start+0x00)
|
.set DMEM_250, (__data_start+0x50)
|
.set DMEM_250, (__data_start+0x50)
|
|
|
.set IE1, 0x0000
|
.set IE1, 0x0000
|
.set IFG1, 0x0002
|
.set IFG1, 0x0002
|
.set WDTCTL, 0x0120
|
.set WDTCTL, 0x0120
|
|
|
|
|
main:
|
main:
|
|
|
/* -------------- WATCHDOG TEST: RD/WR ACCESS --------------- */
|
/* -------------- WATCHDOG TEST: RD/WR ACCESS --------------- */
|
|
|
mov &WDTCTL, r4
|
mov &WDTCTL, r4
|
mov #0x5aff, &WDTCTL
|
mov #0x5aff, &WDTCTL
|
mov &WDTCTL, r5
|
mov &WDTCTL, r5
|
mov #0x5a55, &WDTCTL
|
mov #0x5a55, &WDTCTL
|
mov &WDTCTL, r6
|
mov &WDTCTL, r6
|
mov #0x5aaa, &WDTCTL
|
mov #0x5aaa, &WDTCTL
|
mov &WDTCTL, r7
|
mov &WDTCTL, r7
|
mov #0x5a00, &WDTCTL
|
mov #0x5a00, &WDTCTL
|
mov &WDTCTL, r8
|
mov &WDTCTL, r8
|
|
mov &IFG1, r9
|
|
mov.b #0x00, &IFG1
|
|
|
mov #0x1000, r15
|
mov #0x1000, r15
|
|
|
|
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /64 ------------ */
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /64 ------------ */
|
|
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
eint
|
eint
|
bis.b #0x01, &IE1
|
bis.b #0x01, &IE1
|
|
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter
|
|
|
mov #0x0000, r4
|
mov #0x0000, r4
|
mov #0x0001, r5
|
mov #0x0001, r5
|
wait_loop_64:
|
wait_loop_64:
|
inc r4
|
inc r4
|
cmp #0x3401, r5
|
cmp #0x3401, r5
|
jne wait_loop_64
|
jne wait_loop_64
|
|
|
mov #0x2000, r15
|
mov #0x2000, r15
|
|
|
|
|
|
|
bic.b #0x01, &IE1 ;# Disable watchdog interrupt
|
bic.b #0x01, &IE1 ;# Disable watchdog interrupt
|
|
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter
|
mov #0x0205, r4
|
|
mov &WDTCTL, r5 ;# Check if ACLK is selected
|
|
bit #0x0004, r5
|
|
jnz aclk_sel_64
|
|
mov #0x0012, r4
|
|
aclk_sel_64:
|
|
|
mov #0x0010, r4
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter
|
mov #0x0002, r5
|
mov #0x0002, r5
|
|
|
wait_loop_64_no_irq:
|
wait_loop_64_no_irq:
|
dec r4
|
dec r4
|
cmp #0x0000, r4
|
cmp #0x0000, r4
|
jne wait_loop_64_no_irq
|
jne wait_loop_64_no_irq
|
|
|
mov &IFG1, r6
|
mov &IFG1, r6
|
mov r4, r7
|
mov r4, r7
|
bic.b #0x01, &IFG1 ;# Clear flag
|
bic.b #0x01, &IFG1 ;# Clear flag
|
mov &IFG1, r8
|
mov &IFG1, r8
|
|
|
mov #0x2001, r15
|
mov #0x2001, r15
|
|
|
|
|
|
|
mov #0x5a9b, &WDTCTL ;# Enable interval mode /64 & clear counter & enable hold
|
mov #0x5a9b, &WDTCTL ;# Enable interval mode /64 & clear counter & enable hold
|
|
|
mov #0x0020, r4
|
mov #0x0020, r4
|
mov #0x0022, r5
|
mov #0x0022, r5
|
wait_loop_64_no_irq_hold:
|
wait_loop_64_no_irq_hold:
|
dec r4
|
dec r4
|
cmp #0x0000, r4
|
cmp #0x0000, r4
|
jne wait_loop_64_no_irq_hold
|
jne wait_loop_64_no_irq_hold
|
|
|
mov &IFG1, r6
|
mov &IFG1, r6
|
mov r4, r7
|
mov r4, r7
|
|
|
mov #0x2002, r15
|
mov #0x2002, r15
|
|
|
|
|
|
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter / Check counter clear
|
mov #0x5a1b, &WDTCTL ;# Enable interval mode /64 & clear counter / Check counter clear
|
mov #0x0033, r4
|
mov #0x0033, r4
|
|
|
mov #0x000C, r5
|
mov #0x000C, r5
|
wait_loop_64_no_irq_clear1:
|
wait_loop_64_no_irq_clear1:
|
dec r5
|
dec r5
|
cmp #0x0000, r5
|
cmp #0x0000, r5
|
jne wait_loop_64_no_irq_clear1
|
jne wait_loop_64_no_irq_clear1
|
|
|
mov #0x5a1b, &WDTCTL ;# Clear counter
|
mov #0x5a1b, &WDTCTL ;# Clear counter
|
mov &IFG1, r6
|
mov &IFG1, r6
|
|
|
mov #0x000C, r5
|
mov #0x000C, r5
|
wait_loop_64_no_irq_clear2:
|
wait_loop_64_no_irq_clear2:
|
dec r5
|
dec r5
|
cmp #0x0000, r5
|
cmp #0x0000, r5
|
jne wait_loop_64_no_irq_clear2
|
jne wait_loop_64_no_irq_clear2
|
|
|
mov &IFG1, r7 ;# Don't Clear counter
|
mov &IFG1, r7 ;# Don't Clear counter
|
|
|
mov #0x000C, r5
|
mov #0x000C, r5
|
wait_loop_64_no_irq_clear3:
|
wait_loop_64_no_irq_clear3:
|
dec r5
|
dec r5
|
cmp #0x0000, r5
|
cmp #0x0000, r5
|
jne wait_loop_64_no_irq_clear3
|
jne wait_loop_64_no_irq_clear3
|
|
|
mov &IFG1, r8
|
mov &IFG1, r8
|
bic.b #0x01, &IFG1 ;# Clear flag
|
bic.b #0x01, &IFG1 ;# Clear flag
|
|
|
|
|
mov #0x2003, r15
|
mov #0x2003, r15
|
|
|
|
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /512 ------------ */
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /512 ------------ */
|
|
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
eint
|
eint
|
bis.b #0x01, &IE1
|
bis.b #0x01, &IE1
|
|
|
mov #0x5a1a, &WDTCTL ;# Enable interval mode /512 & clear counter
|
mov #0x5a1a, &WDTCTL ;# Enable interval mode /512 & clear counter
|
|
|
mov #0x0000, r4
|
mov #0x0000, r4
|
mov #0x0003, r5
|
mov #0x0003, r5
|
wait_loop_512:
|
wait_loop_512:
|
inc r4
|
inc r4
|
cmp #0x3403, r5
|
cmp #0x3403, r5
|
jne wait_loop_512
|
jne wait_loop_512
|
|
|
mov #0x3000, r15
|
mov #0x3000, r15
|
|
|
|
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /8192 ------------ */
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /8192 ------------ */
|
|
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
eint
|
eint
|
bis.b #0x01, &IE1
|
bis.b #0x01, &IE1
|
|
|
mov #0x5a19, &WDTCTL ;# Enable interval mode /8192 & clear counter
|
mov #0x5a19, &WDTCTL ;# Enable interval mode /8192 & clear counter
|
|
|
mov #0x0000, r4
|
mov #0x0000, r4
|
mov #0x0004, r5
|
mov #0x0004, r5
|
wait_loop_8192:
|
wait_loop_8192:
|
inc r4
|
inc r4
|
cmp #0x3404, r5
|
cmp #0x3404, r5
|
jne wait_loop_8192
|
jne wait_loop_8192
|
|
|
mov #0x4000, r15
|
mov #0x4000, r15
|
|
|
|
|
|
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /32768 ------------ */
|
/* -------------- WATCHDOG TEST: INTERVAL MODE /32768 ------------ */
|
|
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
mov #DMEM_250, r1 ;# Initialize stack & Enable interrupts
|
eint
|
eint
|
bis.b #0x01, &IE1
|
bis.b #0x01, &IE1
|
|
|
mov #0x5a18, &WDTCTL ;# Enable interval mode /32768 & clear counter
|
mov #0x5a18, &WDTCTL ;# Enable interval mode /32768 & clear counter
|
|
|
mov #0x0000, r4
|
mov #0x0000, r4
|
mov #0x0005, r5
|
mov #0x0005, r5
|
wait_loop_32768:
|
wait_loop_32768:
|
inc r4
|
inc r4
|
cmp #0x3405, r5
|
cmp #0x3405, r5
|
jne wait_loop_32768
|
jne wait_loop_32768
|
|
|
mov #0x5000, r15
|
mov #0x5000, r15
|
|
|
|
|
|
|
|
|
/* ---------------------- END OF TEST --------------- */
|
/* ---------------------- END OF TEST --------------- */
|
end_of_test:
|
end_of_test:
|
nop
|
nop
|
br #0xffff
|
br #0xffff
|
|
|
|
|
/* ---------------------- INTERRUPT ROUTINES --------------- */
|
/* ---------------------- INTERRUPT ROUTINES --------------- */
|
|
|
WDOG_VECTOR:
|
WDOG_VECTOR:
|
bis #0x3400, r5
|
bis #0x3400, r5
|
mov &IFG1, r6
|
mov &IFG1, r6
|
mov r4, r7
|
mov r4, r7
|
reti
|
reti
|
|
|
|
|
/* ---------------------- INTERRUPT VECTORS --------------- */
|
/* ---------------------- INTERRUPT VECTORS --------------- */
|
|
|
.section .vectors, "a"
|
.section .vectors, "a"
|
.word end_of_test ; Interrupt 0 (lowest priority)
|
.word end_of_test ; Interrupt 0 (lowest priority)
|
.word end_of_test ; Interrupt 1
|
.word end_of_test ; Interrupt 1
|
.word end_of_test ; Interrupt 2
|
.word end_of_test ; Interrupt 2
|
.word end_of_test ; Interrupt 3
|
.word end_of_test ; Interrupt 3
|
.word end_of_test ; Interrupt 4
|
.word end_of_test ; Interrupt 4
|
.word end_of_test ; Interrupt 5
|
.word end_of_test ; Interrupt 5
|
.word end_of_test ; Interrupt 6
|
.word end_of_test ; Interrupt 6
|
.word end_of_test ; Interrupt 7
|
.word end_of_test ; Interrupt 7
|
.word end_of_test ; Interrupt 8
|
.word end_of_test ; Interrupt 8
|
.word end_of_test ; Interrupt 9
|
.word end_of_test ; Interrupt 9
|
.word WDOG_VECTOR ; Interrupt 10 Watchdog timer
|
.word WDOG_VECTOR ; Interrupt 10 Watchdog timer
|
.word end_of_test ; Interrupt 11
|
.word end_of_test ; Interrupt 11
|
.word end_of_test ; Interrupt 12
|
.word end_of_test ; Interrupt 12
|
.word end_of_test ; Interrupt 13
|
.word end_of_test ; Interrupt 13
|
.word end_of_test ; Interrupt 14 NMI
|
.word end_of_test ; Interrupt 14 NMI
|
.word main ; Interrupt 15 (highest priority) RESET
|
.word main ; Interrupt 15 (highest priority) RESET
|
|
|