Hi,
I recently got hold of the PICKit 1 from Microchip. Looked at the 'lessons' and learnt nothing (!) , so searched and searched for some REALLY basic asm code on t'internet.
I've managed to get one LED flashing on the demo board, but it seems a little eratic at times, between 2s-10s it looks like it's resetting (the flash rate increases for one cycle).
I'll include the code I've got in a min, but first one question....
what's the difference between 'list p=12F675' and '#include <p12f675.inc>'. I'm guessing the latter is just to give you some of the extra pre-defined 'equ' statements to use in your code? but what EXACTLY does the 'list' command do? Is it used to create the HEX code? or included, and dealt with inside the 'programmer'?
thanks for any guidence in advance, this is all new territory for me, i'm more a C/Perl developer.
well, here's my code so far...
list p=12F675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;*****Set up the Constants****
COUNT1 equ 20h ;First counter for our delay loops
COUNT2 equ 21h ;Second counter for our delay loops
;****Set up the port****
clrf GPIO
movlw 0x7
movwf CMCON ; disable comparator
bsf STATUS, RP0
movlw B'00001111'
movwf TRISIO ; All pins outputs
bcf STATUS, RP0
;****Turn the LED on****
Start
movlw b'00100000' ;Turn the LED on by first putting
movwf GPIO ;it into the w register and then
;****Start of the delay loop 1****
call Delay
;****Delay finished, now turn the LED off****
movlw b'00000000' ;Turn the LED off by first putting
movwf GPIO ;it into the w register and then on
;****Add another delay****
call Delay
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED
Delay
Loop1
decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1 ;
return
;****End of the program****
end
I recently got hold of the PICKit 1 from Microchip. Looked at the 'lessons' and learnt nothing (!)
I've managed to get one LED flashing on the demo board, but it seems a little eratic at times, between 2s-10s it looks like it's resetting (the flash rate increases for one cycle).
I'll include the code I've got in a min, but first one question....
what's the difference between 'list p=12F675' and '#include <p12f675.inc>'. I'm guessing the latter is just to give you some of the extra pre-defined 'equ' statements to use in your code? but what EXACTLY does the 'list' command do? Is it used to create the HEX code? or included, and dealt with inside the 'programmer'?
thanks for any guidence in advance, this is all new territory for me, i'm more a C/Perl developer.
well, here's my code so far...
list p=12F675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;*****Set up the Constants****
COUNT1 equ 20h ;First counter for our delay loops
COUNT2 equ 21h ;Second counter for our delay loops
;****Set up the port****
clrf GPIO
movlw 0x7
movwf CMCON ; disable comparator
bsf STATUS, RP0
movlw B'00001111'
movwf TRISIO ; All pins outputs
bcf STATUS, RP0
;****Turn the LED on****
Start
movlw b'00100000' ;Turn the LED on by first putting
movwf GPIO ;it into the w register and then
;****Start of the delay loop 1****
call Delay
;****Delay finished, now turn the LED off****
movlw b'00000000' ;Turn the LED off by first putting
movwf GPIO ;it into the w register and then on
;****Add another delay****
call Delay
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED
Delay
Loop1
decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1 ;
return
;****End of the program****
end