--- In lpc2000@yahoogroups.com, Tom Walsh <tom@...> wrote:
>
> Danish Ali wrote:
>
> >Seeing that the system did work if I placed a manual delay between
> >watchdog feeds, I tried only feeding the watchdog once every keyboard
> >scan (polled from a timer flag in the event loop, no faster than once
> >
> >
> That is suspicious! I would look very carefully at the assembly
> language being generated by the compiler to ensure what I said in C
> actually is being done in assembler (opcode level). Never assume.
>
Hi Tom,
Good point, particularly as I hadn't included any source code
let alone the resulting assembly code.
When you view my watchdog feed routine, note that I do not
have anything set up to cause a FIQ. (I have not yet decided
which of my interrupt routines should be fast).
I don't have the hardware to hand (it is on its way back from
a trade show in Germany) where the system seemed to work. But
I had nothing hanging off the diagnostics port so I don't
know that for sure.
Regards,
Danish
The C source code is:
void Watchdog_Feed(void) {
/* This code DOES NOT WORK if FIQ is used */
/* read IRQ status. If it is enabled, disable it
feed watchdog
restore IRQ status */
int irqStat;
asm volatile (
" mrs r0, cpsr\n"
" mov %0,r0\n" : "=r" (irqStat) : : "r0" );
/* bit 7 of cpsr is set to disable IRQ */
if (128 & ~irqStat)
__ARMLIB_disableIRQ();
asm volatile (
"WDFEED = 0xE0000008\n"
" LDR r0, =WDFEED\n"
" MOV r1,#0xAA\n"
" MOV r2,#0x55\n"
" STRB r1,[r0]\n"
" STRB r2,[r0]\n" : : : "r0", "r1", "r2");
if (128 & ~irqStat)
__ARMLIB_enableIRQ();
}
with the crossworks IRQ enable and disable routines being:
<__ARMLIB_enableIRQ>:
E92D0001 stmfd sp!, {r0}
E10F0000 mrs r0, cpsr
E3C00080 bic r0, r0, #0x00000080
E12FF000 msr cpsr_cxsf, r0
E8BD0001 ldmfd sp!, {r0}
E12FFF1E bx lr
<__ARMLIB_disableIRQ>:
E92D0001 stmfd sp!, {r0}
E10F0000 mrs r0, cpsr
E3800080 orr r0, r0, #0x00000080
E12FF000 msr cpsr_cxsf, r0
E8BD0001 ldmfd sp!, {r0}
E12FFF1E bx lr
The full disassembly of Watchdog_Feed is:
void Watchdog_Feed(void) {
E1A0C00D mov r12, sp
E92DD800 stmfd sp!, {r11-r12, lr-pc}
E24CB004 sub r11, r12, #0x00000004
E24DD004 sub sp, sp, #0x00000004
int irqStat;
asm volatile (
E10F0000 mrs r0, cpsr
E1A03000 mov r3, r0
E50B3010 str r3, [r11, #-16]
" mrs r0, cpsr\n"
" mov %0,r0\n" : "=r" (irqStat) : : "r0" );
if (128 & ~irqStat)
E51B3010 ldr r3, [r11, #-16]
E1E03003 mvn r3, r3
E2033080 and r3, r3, #0x00000080
E3530000 cmp r3, #0x00000000
0A000000 beq 0x000033E8
__ARMLIB_disableIRQ();
EB001A7D bl 0x00009DE0 <__ARMLIB_disableIRQ>
asm volatile (
E3A0028E mov r0, #0xE0000008
E3A010AA mov r1, #0x000000AA
E3A02055 mov r2, #0x00000055
E5C01000 strb r1, [r0]
E5C02000 strb r2, [r0]
" MOV r1,#0xAA\n"
" MOV r2,#0x55\n"
" STRB r1,[r0]\n"
" STRB r2,[r0]\n" : : : "r0", "r1", "r2");
if (128 & ~irqStat)
E51B3010 ldr r3, [r11, #-16]
E1E03003 mvn r3, r3
E2033080 and r3, r3, #0x00000080
E3530000 cmp r3, #0x00000000
0A000000 beq 0x00003414
__ARMLIB_enableIRQ();
EB001A6C bl 0x00009DC8 <__ARMLIB_enableIRQ>
}
E24BD00C sub sp, r11, #0x0000000C
E89D6800 ldmfd sp, {r11, sp-lr}
E12FFF1E bx lrMessage
Re: Do not over-feed the Watchdog (?)
2006-04-04 by Danish Ali
Attachments
- No local attachments were found for this message.