Hi there,
I just made a code for LED blinking with brightness control but, it is too long, see for your self.......
Now, I want to make a macro for this part.....
I know that there is macro tool available in MPLAB IDE but, I don't know how to generate macro, I see the record and "keyboard follow " and "mouse follow" option but I am confused about it, do I need to move cursor with arrow keys along the code while recording ?, will just writing above program generate the macro for it ? I will be very thankful if someone actually show me form the scratch that how to generate macro, if possible please explain me with the above code. From the very start (what to include and not, you know from the first line called "list") I tried goggling but there are very difficult and huge examples and libraries, Please help me.
I just made a code for LED blinking with brightness control but, it is too long, see for your self.......
Code:
List p=16f690
#include<p16f690.inc>
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
ERRORLEVEL-302
;**********************************************************************
cblock 0x20
temp
d1
d2
don
doff
dis
endc
;***********************************************************************
org 0x00
goto main
;***********************************************************************
main:
portset:
bsf STATUS,RP0
clrf TRISA
clrf TRISB
clrf TRISC
bcf STATUS,RP0
start: ; THE BASIC FUNDA OF THIS PROGRAM IS THAT LOOP
call bright ;"bright" SHOULD KEEP RUNNING DURING "delay" OR IN OTHER
movlw b'00000000' ;WORDS EQUAL TO THAT TIME PERIOD WHICH IS USED IN HERE.
movwf PORTC
call delay
goto start
delay:
decfsz d1
goto delay
decfsz d2
goto delay
return
bright:
incf dis,f
movlw b'00000001'
movwf PORTC
call delayons
movlw b'00000000'
movwf PORTC
call delayoffs
btfss dis,0x00
goto bright
btfss dis,0x01
goto bright
btfss dis,0x02
goto bright
btfss dis,0x03
goto bright
btfss dis,0x04
goto bright
btfss dis,0x05
goto bright
btfss dis,0x06
goto bright
btfss dis,0x07
goto bright
clrf dis
return
delayons:
movlw d'30'
movwf don
delayon:
decfsz don
goto delayon
return
delayoffs:
movlw d'226'
movwf doff
delayoff:
decfsz doff
goto delayoff
return
end
Code:
bright:
incf dis,f
movlw b'00000001'
movwf PORTC
call delayons
movlw b'00000000'
movwf PORTC
call delayoffs
btfss dis,0x00
goto bright
btfss dis,0x01
goto bright
btfss dis,0x02
goto bright
btfss dis,0x03
goto bright
btfss dis,0x04
goto bright
btfss dis,0x05
goto bright
btfss dis,0x06
goto bright
btfss dis,0x07
goto bright
clrf dis
return