goodpickles
New Member
Hello!
I am having problems putting a pic 12f629 into low-power mode.
Before the sleep command the power consumption is 540ua and afterwards it is 47ua (so I think it is actually getting the sleep command. ) Sleep current should be 4ua...or am I misreading something?
I have nothing connected to any pins other then 3 volts + and - on vdd and vcc
I have written my code in pic simulator’s basic compiler. Following is the code.
If you need to see the assembly code here it is:
I would greatly appreciate if you have any idea what is wrong, or if you know if my problem is hardware, or software related.
I am having problems putting a pic 12f629 into low-power mode.
Before the sleep command the power consumption is 540ua and afterwards it is 47ua (so I think it is actually getting the sleep command. ) Sleep current should be 4ua...or am I misreading something?
I have nothing connected to any pins other then 3 volts + and - on vdd and vcc
I have written my code in pic simulator’s basic compiler. Following is the code.
Code:
TRISIO = %000000
Dim count2 As Word
count2 = 0
start:
GPIO = %111000
WaitMs 10
GPIO = %000111
WaitMs 10
If count2 > 20 Then 'should be 16000
count2 = 0
GPIO = %000000
WaitMs 5000
ASM: sleep
Else
count2 = count2 + 1
Endif
Goto start
End
If you need to see the assembly code here it is:
Code:
; Begin
R0L EQU 0x20
R0H EQU 0x21
R1L EQU 0x22
R1H EQU 0x23
R2L EQU 0x24
R2H EQU 0x25
R3L EQU 0x26
R3H EQU 0x27
R4L EQU 0x28
R4H EQU 0x29
R5L EQU 0x2A
R5H EQU 0x2B
ORG 0x0000
BCF PCLATH,3
BCF PCLATH,4
GOTO L0002
ORG 0x0004
RETFIE
L0002:
; 1: 'INTCON.GPIE = 1 'enable b0 int.
; 2: 'INTCON.GIE = True 'enable all un-masked interrupts
; 3: TRISIO = %000000
BSF STATUS,RP0
CLRF 0x05
BCF STATUS,RP0
; 4: Dim count2 As Word
; The address of 'count2' is 0x2C
count2 EQU 0x2C
; 5: count2 = 0
CLRF 0x2C
CLRF 0x2D
; 6:
; 7:
; 8: start:
L0001:
; 9: GPIO = %111000
MOVLW 0x38
MOVWF 0x05
; 10: WaitMs 10
MOVLW 0x0A
MOVWF R0L
CLRF R0H
CALL W001
; 11: GPIO = %000111
MOVLW 0x07
MOVWF 0x05
; 12: WaitMs 10
MOVLW 0x0A
MOVWF R0L
CLRF R0H
CALL W001
; 13:
; 14: If count2 > 20 Then 'should be 16000
MOVF 0x2C,W
MOVWF R0L
MOVF 0x2D,W
MOVWF R0H
CLRF R1H
MOVLW 0x14
CALL C003
BTFSS STATUS,Z
GOTO L0003
; 15: count2 = 0
CLRF 0x2C
CLRF 0x2D
; 16: GPIO = %000000
CLRF 0x05
; 17: WaitMs 5000
MOVLW 0x88
MOVWF R0L
MOVLW 0x13
MOVWF R0H
CALL W001
; 18: ASM: sleep
sleep
; 19: Else
GOTO L0004
L0003: MOVLW 0x1F
ANDWF STATUS,F
; 20: count2 = count2 + 1
MOVF 0x2C,W
ADDLW 0x01
MOVWF 0x2C
MOVF 0x2D,W
BTFSC STATUS,C
ADDLW 0x01
ADDLW 0x00
MOVWF 0x2D
; 21: Endif
L0004: MOVLW 0x1F
ANDWF STATUS,F
; 22: Goto start
GOTO L0001
; 23:
; 24:
; 25:
; 26:
; 27:
; 28:
; 29: End
L0005: GOTO L0005
; 30:
; 31: 'On Interrupt
; 32: 'count2 = 0
; 33:
; 34: 'INTCON.GPIF = 0
; 35: 'Resume
; 36:
; 37:
; End of program
L0006: GOTO L0006
; Comparison Routine
C001: MOVWF R1L
MOVLW 0x05
GOTO C007
C002: MOVWF R1L
MOVLW 0x02
GOTO C007
C003: MOVWF R1L
MOVLW 0x06
GOTO C007
C004: MOVWF R1L
MOVLW 0x03
GOTO C007
C005: MOVWF R1L
MOVLW 0x04
GOTO C007
C006: MOVWF R1L
MOVLW 0x01
GOTO C007
C007: MOVWF R4L
MOVF R1H,W
SUBWF R0H,W
BTFSS STATUS,Z
GOTO C008
MOVF R1L,W
SUBWF R0L,W
C008: MOVLW 0x04
BTFSC STATUS,C
MOVLW 0x01
BTFSC STATUS,Z
MOVLW 0x02
ANDWF R4L,W
BTFSS STATUS,Z
MOVLW 0xFF
RETURN
; Waitms Routine
W001: MOVF R0L,F
BTFSC STATUS,Z
GOTO W002
CALL W003
DECF R0L,F
NOP
NOP
NOP
NOP
NOP
GOTO W001
W002: MOVF R0H,F
BTFSC STATUS,Z
RETURN
CALL W003
DECF R0H,F
DECF R0L,F
GOTO W001
W003: MOVLW 0x0C
MOVWF R2H
W004: DECFSZ R2H,F
GOTO W004
NOP
NOP
MOVLW 0x12
MOVWF R1L
W005: DECFSZ R1L,F
GOTO W006
CALL W007
CALL W007
NOP
NOP
RETURN
W006: CALL W007
GOTO W005
W007: MOVLW 0x0D
MOVWF R2L
W008: DECFSZ R2L,F
GOTO W008
NOP
RETURN
; End of listing
END
I would greatly appreciate if you have any idea what is wrong, or if you know if my problem is hardware, or software related.