I am new to the Pic Micro scene and am learning during my spare time, my main goal it to learn about software PWM, I have managed to learn some of the basics with www.winpicprog.co.uk.
I have successfully flashed LED's with the 16F628 but i want to use the 12F629 at the moment less ports registers etc...
I have read 'PIC in Practice by DW Smith' it is also my main learning guide, I used the following code to turn on and off GPIO 1 pin 6.
;HEADER FOR 12F629
;
;
;
;
TMR0 EQU 1 ;TMR0 is FILE 1.
TRSIO EQU 85H
GPIO EQU 5 ;GPIO is FILE 5.
STATUS EQU 3 ;STATUS is FILE 3.
ZEROBIT EQU 2 ;ZEROBIT is FILE 2.
GO EQU 1
OPTION_R EQU 81H
CMCOM EQU 19H
OSCCAL EQU 90H
COUNT EQU 20H ;USER RAM LOCATION
;*******************************************************
LIST P=12F629
ORG 0
GOTO START
;*******************************************************
;Configuration Bits
_CONFIG H'3F84'
;*******************************************************
;SUBROUTINE SECTION
;1/100 SECOND DELAY
DELAY CLRF TMR0 ;START TMR0
LOOPA MOVF TMR0,W ;READ TMR0 IN W
SUBLW .39 ;TIME - W
BTFSS STATUS,ZEROBIT ;CHECK TIME-W=0
GOTO LOOPA
RETLW 0 ;RETURN AFTER TMR0=39
;P1 SECOND DELAY
DELAYP1 MOVLW .10
MOVWF COUNT
TIMEC CALL DELAY
DECFSZ COUNT
GOTO TIMEC
RETLW 0
;**********************************************************
;CONFIGERATION SECTION
START BSF STATUS,5 ;BANK1
MOVLW B'00001001' ;BITS 0,3 ARE I/P
MOVWF TRISO
MOVLW B'00000111'
MOVWF OPTION_R ;PRESCALER is /256
CALL 3FFH
MOVWF OSCCAL ;Calibrates 4MHZ oscillator
BCF STATUS,5 ;BANK0
MOVLW 7H
MOVWF COMCON
CLRF GPIO
;***********************************************************
;Program Starts Now.
BEGIN MOVLW B'00000010' ;turn on LED1
MOVWF GPIO
CALL DELAYP1
MOVLW B'00000000' ;TURN OFF LED1
MOVWF GPIO
CALL DELAYP1
GOTO BEGIN
END
I keep getting errors with the compiler MPLAB IDE. Where am I going wrong, please don't post the answer, point me in the right direction I want to learn and not be showen.
Also when using the tutorials on www.winpicprog.co.uk for the 16F628 the code does not use the EQUates section, why is it in all the code examples in my 'PIC in practice book' ?
Is it because some compilers don`t know where the GPIO or STATUS registers are?
Thanks for any help
I have successfully flashed LED's with the 16F628 but i want to use the 12F629 at the moment less ports registers etc...
I have read 'PIC in Practice by DW Smith' it is also my main learning guide, I used the following code to turn on and off GPIO 1 pin 6.
;HEADER FOR 12F629
;
;
;
;
TMR0 EQU 1 ;TMR0 is FILE 1.
TRSIO EQU 85H
GPIO EQU 5 ;GPIO is FILE 5.
STATUS EQU 3 ;STATUS is FILE 3.
ZEROBIT EQU 2 ;ZEROBIT is FILE 2.
GO EQU 1
OPTION_R EQU 81H
CMCOM EQU 19H
OSCCAL EQU 90H
COUNT EQU 20H ;USER RAM LOCATION
;*******************************************************
LIST P=12F629
ORG 0
GOTO START
;*******************************************************
;Configuration Bits
_CONFIG H'3F84'
;*******************************************************
;SUBROUTINE SECTION
;1/100 SECOND DELAY
DELAY CLRF TMR0 ;START TMR0
LOOPA MOVF TMR0,W ;READ TMR0 IN W
SUBLW .39 ;TIME - W
BTFSS STATUS,ZEROBIT ;CHECK TIME-W=0
GOTO LOOPA
RETLW 0 ;RETURN AFTER TMR0=39
;P1 SECOND DELAY
DELAYP1 MOVLW .10
MOVWF COUNT
TIMEC CALL DELAY
DECFSZ COUNT
GOTO TIMEC
RETLW 0
;**********************************************************
;CONFIGERATION SECTION
START BSF STATUS,5 ;BANK1
MOVLW B'00001001' ;BITS 0,3 ARE I/P
MOVWF TRISO
MOVLW B'00000111'
MOVWF OPTION_R ;PRESCALER is /256
CALL 3FFH
MOVWF OSCCAL ;Calibrates 4MHZ oscillator
BCF STATUS,5 ;BANK0
MOVLW 7H
MOVWF COMCON
CLRF GPIO
;***********************************************************
;Program Starts Now.
BEGIN MOVLW B'00000010' ;turn on LED1
MOVWF GPIO
CALL DELAYP1
MOVLW B'00000000' ;TURN OFF LED1
MOVWF GPIO
CALL DELAYP1
GOTO BEGIN
END
I keep getting errors with the compiler MPLAB IDE. Where am I going wrong, please don't post the answer, point me in the right direction I want to learn and not be showen.
Also when using the tutorials on www.winpicprog.co.uk for the 16F628 the code does not use the EQUates section, why is it in all the code examples in my 'PIC in practice book' ?
Is it because some compilers don`t know where the GPIO or STATUS registers are?
Thanks for any help