Hi
This is my first post here. I need some advice on modifying 16F84 code for 16F627/8. I am trying to learn myself assembly language from
http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
The tutorial uses a 16F84 for all there explanations.
Now to the problem. I am stuck on "delay loops" I have burned the example code from the tutorial to both my pics. (16F627/8).
The example code is supposed to make a LED on pin 18 of the pic oscillate. When I applied power to the little circuit the Led didnt oscilate at all. I did check it with a scope. I aslo don't know how to use a external Rc oscillator for the pic, so I used a 32.768khz crystal.
Last but not least. Ive readed the datasheet on my pics, and according to it, I should first disable the comparators. Ive used the datasheets small example code to disable it, but then when the computer put the code together it shows errors.
Any help would be great
Here is the code:
This is my first post here. I need some advice on modifying 16F84 code for 16F627/8. I am trying to learn myself assembly language from
http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
The tutorial uses a 16F84 for all there explanations.
Now to the problem. I am stuck on "delay loops" I have burned the example code from the tutorial to both my pics. (16F627/8).
The example code is supposed to make a LED on pin 18 of the pic oscillate. When I applied power to the little circuit the Led didnt oscilate at all. I did check it with a scope. I aslo don't know how to use a external Rc oscillator for the pic, so I used a 32.768khz crystal.
Last but not least. Ive readed the datasheet on my pics, and according to it, I should first disable the comparators. Ive used the datasheets small example code to disable it, but then when the computer put the code together it shows errors.
Any help would be great
Here is the code:
Rich (BB code):
;*****Set up the Constants****
STATUS equ 03h ;Address of the STATUS register
TRISA equ 85h ;Address of the tristate register for port A
PORTA equ 05h ;Address of Port A
COUNT1 equ 08h ;First counter for our delay loops
COUNT2 equ 09h ;Second counter for our delay loops
CMCON equ 1Fh
; Turn off coparators ;
movlw 07h
movwf CMCON
;****Set up the port****
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output.
bcf STATUS,5 ;Switch back to Bank 0
;****Turn the LED on****
Start movlw 02h ;Turn the LED on by first putting
movwf PORTA ;it into the w register and then
;on the port
;****Start of the delay loop 1****
Loop1 decfsz COUNT1,1 ;Subtract 1 from 255
goto Loop1 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop1 ;Go back to the start of our loop.
;This delay counts down from
;255 to zero, 255 times
;****Delay finished, now turn the LED off****
movlw 00h ;Turn the LED off by first putting
movwf PORTA ;it into the w register and then on
;the port
;****Add another delay****
Loop2 decfsz COUNT1,1 ;This second loop keeps the
goto Loop2 ;LED turned off long enough for
decfsz COUNT2,1 ;us to see it turned off
goto Loop2 ;
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED
;on again
;****End of the program****
end