PIC18fxx Reset and WDT trouble

Hi, can anyone help please? I've started to use the high-end family of

18f PICs and I just can't seem to get the WDT wake-up working. All I want to do is pulse a Green LED once for 1/2 second on applying power and then enter SLEEP for 2.3 seconds, wake-up, pulse a Red LED for 1/2 second then repeat the SLEEP, waking to flash the Red LED every 2.3 seconds. I've set the configuration bits accordingly and the DELAY subroutine works fine and all interrupts are diabled. Just can't seem to see where I'm going wrong. Any advice would be most appreciated.

Simon

list p=18f252 include

; Oscillator Source : 4 Mhz External Oscillator ; Watchdog Timer: Disabled - Controlled by SWDTEN bit ; Watchdog Postscaler: 1:128

ORG 0x000000 ;Reset vector GOTO COLD_START ORG 0x000008 ;High priority interrupt vector GOTO COLD_START ORG 0x000018 ;Low priority interrupt vector GOTO COLD_START

; Power-Up

COLD_START BCF WDTCON,SWDTEN ;Ensure WDT is disabled. CLRF PORTA ;Clear port data latches. MOVLW H'07' ;Configure A/D for all MOVWF ADCON1 ;port bits digital. CLRF TRISA ;RA0-RA5=outputs. CLRF PORTB MOVLW B'00000011' ;RB0:RB1=inputs MOVWF TRISB ;RB2-RB7=outputs. CLRF PORTC CLRF TRISC ;RC0-RC7=outputs.

; Determine start condition ; ;| TO | PD | BTFSC RCON,PD ;| 0 | 0 | WDT wake-up. GOTO MAIN ;| 0 | 1 | WDT Reset. BTFSC RCON,TO ;| 1 | 0 | MCLR wakeup. GOTO MAIN ;| 1 | 1 | Power-on Reset. ; ; Service WDT wake-up ; BCF WDTCON,SWDTEN ;Ensure Watchdog=OFF. BSF RED MOVLW HALF_SEC CALL DELAY BCF RED SNOOZE BSF WDTCON,SWDTEN SLEEP ; ; Start-up ; MAIN BSF GREEN MOVLW HALF_SEC CALL DELAY BCF GREEN GOTO SNOOZE ; END

Reply to
PigPOg
Loading thread data ...

I don't see where you've configured the fuses to enable the watchdog. Did you just not post that part?

DLC

: Hi, can anyone help please? I've started to use the high-end family of : 18f PICs and I just can't seem to get the WDT wake-up working. All I : want to do is pulse a Green LED once for 1/2 second on applying power : and then enter SLEEP for 2.3 seconds, wake-up, pulse a Red LED for 1/2 : second then repeat the SLEEP, waking to flash the Red LED every 2.3 : seconds. I've set the configuration bits accordingly and the DELAY : subroutine works fine and all interrupts are diabled. Just can't seem : to see where I'm going wrong. Any advice would be most appreciated.

: Simon

: list p=18f252 : include

: ; Oscillator Source : 4 Mhz External Oscillator : ; Watchdog Timer: Disabled - Controlled by SWDTEN bit : ; Watchdog Postscaler: 1:128

: ORG 0x000000 ;Reset vector : GOTO COLD_START : ORG 0x000008 ;High priority interrupt vector : GOTO COLD_START : ORG 0x000018 ;Low priority interrupt vector : GOTO COLD_START

: ; Power-Up

: COLD_START : BCF WDTCON,SWDTEN ;Ensure WDT is disabled. : CLRF PORTA ;Clear port data latches. : MOVLW H'07' ;Configure A/D for all : MOVWF ADCON1 ;port bits digital. : CLRF TRISA ;RA0-RA5=outputs. : CLRF PORTB : MOVLW B'00000011' ;RB0:RB1=inputs : MOVWF TRISB ;RB2-RB7=outputs. : CLRF PORTC : CLRF TRISC ;RC0-RC7=outputs.

: ; Determine start condition : ; : ;| TO | PD | : BTFSC RCON,PD ;| 0 | 0 | WDT wake-up. : GOTO MAIN ;| 0 | 1 | WDT Reset. : BTFSC RCON,TO ;| 1 | 0 | MCLR wakeup. : GOTO MAIN ;| 1 | 1 | Power-on Reset. : ; : ; Service WDT wake-up : ; : BCF WDTCON,SWDTEN ;Ensure Watchdog=OFF. : BSF RED : MOVLW HALF_SEC : CALL DELAY : BCF RED : SNOOZE BSF WDTCON,SWDTEN : SLEEP : ; : ; Start-up : ; : MAIN BSF GREEN : MOVLW HALF_SEC : CALL DELAY : BCF GREEN : GOTO SNOOZE : ; : END

--
============================================================================
* Dennis Clark         dlc@frii.com                www.techtoystoday.com   * 
* "Programming and Customizing the OOPic Microcontroller" Mcgraw-Hill 2003 *    
============================================================================
Reply to
Dennis Clark

Hi Dennis

You're right - I didn't post that bit but the WDT is configured correctly. What I did'nt mention was the fact that I'm using the ICE2000 and PCM18XHO and I think that the kit does'nt emulate WDT action. I'm still investigating...

Cheers, Sim>PigPOg wrote:

Reply to
PigPOg

PigPOg wrote: Oh yeah,

I use the Microchip ICD-2 for ICD, and it turns the WDT off when it sets up fuses. I'll bet that your ICE is also disabling the WDT.

DLC

: Hi Dennis

: You're right - I didn't post that bit but the WDT is configured : correctly. What I did'nt mention was the fact that I'm using the : ICE2000 and PCM18XHO and I think that the kit does'nt emulate WDT : action. I'm still investigating...

: Cheers, : Sim : >PigPOg wrote: : >

: > I don't see where you've configured the fuses to enable the watchdog. : >Did you just not post that part? : >

: >DLC : >

: >: Hi, can anyone help please? I've started to use the high-end family of : >: 18f PICs and I just can't seem to get the WDT wake-up working. All I : >: want to do is pulse a Green LED once for 1/2 second on applying power : >: and then enter SLEEP for 2.3 seconds, wake-up, pulse a Red LED for 1/2 : >: second then repeat the SLEEP, waking to flash the Red LED every 2.3 : >: seconds. I've set the configuration bits accordingly and the DELAY : >: subroutine works fine and all interrupts are diabled. Just can't seem : >: to see where I'm going wrong. Any advice would be most appreciated. : >

: >: Simon : >

: >: list p=18f252 : >: include : >

: >: ; Oscillator Source : 4 Mhz External Oscillator : >: ; Watchdog Timer: Disabled - Controlled by SWDTEN bit : >: ; Watchdog Postscaler: 1:128 : >

: >: ORG 0x000000 ;Reset vector : >: GOTO COLD_START : >: ORG 0x000008 ;High priority interrupt vector : >: GOTO COLD_START : >: ORG 0x000018 ;Low priority interrupt vector : >: GOTO COLD_START : >

: >: ; Power-Up : >

: >: COLD_START : >: BCF WDTCON,SWDTEN ;Ensure WDT is disabled. : >: CLRF PORTA ;Clear port data latches. : >: MOVLW H'07' ;Configure A/D for all : >: MOVWF ADCON1 ;port bits digital. : >: CLRF TRISA ;RA0-RA5=outputs. : >: CLRF PORTB : >: MOVLW B'00000011' ;RB0:RB1=inputs : >: MOVWF TRISB ;RB2-RB7=outputs. : >: CLRF PORTC : >: CLRF TRISC ;RC0-RC7=outputs. : >

: >: ; Determine start condition : >: ; : >: ;| TO | PD | : >: BTFSC RCON,PD ;| 0 | 0 | WDT wake-up. : >: GOTO MAIN ;| 0 | 1 | WDT Reset. : >: BTFSC RCON,TO ;| 1 | 0 | MCLR wakeup. : >: GOTO MAIN ;| 1 | 1 | Power-on Reset. : >: ; : >: ; Service WDT wake-up : >: ; : >: BCF WDTCON,SWDTEN ;Ensure Watchdog=OFF. : >: BSF RED : >: MOVLW HALF_SEC : >: CALL DELAY : >: BCF RED : >: SNOOZE BSF WDTCON,SWDTEN : >: SLEEP : >: ; : >: ; Start-up : >: ; : >: MAIN BSF GREEN : >: MOVLW HALF_SEC : >: CALL DELAY : >: BCF GREEN : >: GOTO SNOOZE : >: ; : >: END

--
============================================================================
* Dennis Clark         dlc@frii.com                www.techtoystoday.com   * 
* "Programming and Customizing the OOPic Microcontroller" Mcgraw-Hill 2003 *    
============================================================================
Reply to
Dennis Clark

You are right Dennis - the kit won't emulate the WDT.

Regards, Sim>PigPOg wrote:

Reply to
PigPOg

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.