I tried to program the PIC 12F675 so it would blink an LED diode connected to its GPIO 0 pin (pin number 7).
I have set the pins to digital mode:
clrf ANSEL
I have set them all as outputs:
clrf TRISIO
and finally this is the loop I used:
;this delay loop should consume 1 000 000 ticks
;which is 1 second approximately
movlw 0xff ;assigned the highest 8bit value to accumulator
movwf 0x20 ;moved the value to general purpose register 20
movwf 0x21 ;moved the value to GPR 21
clrw ;cleared the working register (accumulator)
movlw 0x15 ;assigned the value 15 to accumulator
movwf 0x22 ;moved the value to GPR 22
bsf GPIO,0 ;set the first pin high
loop1
decfsz 0x20, 1
goto loop1
decfsz 0x21, 1
goto loop1
decfsz 0x22, 1
goto loop1 ;nested loops to delay further action
bcf GPIO,0 ;set the first pin low
And finally this is the code I used to configure the chip in the fist place:
__CONFIG _FOSC_INTRCIO & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_OFF & _CP_OFF & _CPD_ON
My issue is: when compiling the program in MPLAB X and debugging it step-by-step, there is no problem in program execution, the bit GPIO 0 indeed changes its state according to the loop. But when I connect the chip to breadboard the LED fails to blink, just stays on.
My question is: could the issue be caused by the faulty oscillator configuration? (I also use 100 nF decoupling ceramic capacitor)
I already tried quite a number of code variations. Any advice is welcome.
The whole .asm code that i use:
list p=12F675
#include <p12F675.inc>
__CONFIG _FOSC_INTRCIO & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_OFF & _CP_OFF & _CPD_ON
OSCCAL equ 0x90
TRISIO equ 0x85
ANSEL equ 0x9f
GPIO equ 0x05
org 0x00
bsf 0x03,5 ;bank1
movlw b'00111100' ;osccal value
clrf OSCCAL
movwf OSCCAL ;osccal set
movlw b'11111110' ;ansel value
movwf ANSEL ;set pin AN0 as digital I/O
movlw b'11111110' ;trisio value
movfw TRISIO ;set pin GPIO0 as output
clrf TRISIO
bcf 0x83,5 ;bank0
clrf GPIO ;clear GPIO port
start
movlw 0xff
movwf 0x20
movwf 0x21
clrw
movlw 0x15
movwf 0x22
bsf GPIO,0
loop1
decfsz 0x20, 1
goto loop1
decfsz 0x21, 1
goto loop1
decfsz 0x22, 1
goto loop1
bcf GPIO,0
movlw 0xff
movwf 0x20
movwf 0x21
clrw
movlw 0x15
movwf 0x22
loop2
decfsz 0x20, 1
goto loop2
decfsz 0x21, 1
goto loop2
decfsz 0x22, 1
goto loop2
goto start
end