I'm currently working on a project using the FRDM-KL25Z development board and programming using Keil MDK-lite (5.14a). What we're supposed to do is create a simple traffic light using three corresponding LEDs and a push button to expedite the light change(not immediately like a real traffic light but to check after each delay). The problem I'm having is my program works perfectly fine in the simulator but when running on the development board it reset itself almost immediately. I've narrowed it down to the loops I'm using for a 30 second delay. Any tips to find out why this is happening or how to find more information in the debugger would be great.
Here's a cutout of the loop I'm using.
reset LDR R1, =0x00000002 ;Change light to red BL changelight ; LDR R3, =0x00000011 ;Put value into counter (1 loop just to show code works) d30_1 BL buttonpress ;Check for button press SUBS R3, #17 ;Subtract # of ticks in loop (17) from counter CMP R3, #0 BGT d30_1 CMP R6, #1 ;Check for button press BEQ reset ;Reset to red if pressed LDR R1, =0x00000010 ;Change light to green BL changelight ; LDR R3, =0x05B8d800 ;Put value into counter (5 seconds, the board resets when counter is this high) d30_2 BL buttonpress ;Check for button press SUBS R3, #17 ;Subtract # of ticks in loop (17) from counter CMP R3, #0 BGT d30_2 ...
Here is the branch buttonpress
buttonpress LDR R0, =0x400FF090 ;Put address of PORTC_PDIR into R0 LDR R1, [R0] ;Put value of PORTC_PDIR into R1 LDR R0, =0x00000080 ;Put value of monitored input pin TST R1, R0 ;Check for button press BNE nopress ;Break from process if button not pressed MOVS R6, #1 ;Put 1 in R6 if button has been pressed nopress BX LR