;This code uses our canned delay loop to flash all of the LED's on PORTC list p=16F1455 ; list directive to define processor #include "p16F1455.inc" ; processor specific variable definitions __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON __CONFIG _CONFIG2, _WRT_OFF & _CPUDIV_NOCLKDIV & _USBLSCLK_48MHz & _PLLMULT_3x & _PLLEN_DISABLED & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_ON errorlevel -302 , -207 ; suppress message 302 from list file banksel OSCCON movlw B'00111110' movwf OSCCON banksel TRISC clrf TRISC banksel TRISC ; everything above this line is simply setting up the processor at 16 MHz, using PORTC as our output for LED's. Go ahead and copy & paste it. mainloop: movlw h'FF' movwf LATC ; turn on all of the LED's on PORTC movlw D'10' movwf H'072' ; load up our third RAM with whatever decimal number is in the W register in the line above. This is how many times we'll call the utility delay. ; We control how long the delay is with this number because everytime we call the utility_delay, we add 0.05 seconds to the delay ; This current delay will be approximately 10 X 0.05 = 0.5 seconds. delay_on: call utility_delay ; every time we hit this line, we wait around for 0.05 seconds decfsz H'072', 1 ; every time we come back from the utility delay, we count down on our third register till we hit 0. Then we turn the LED's off. goto delay_on clrf LATC ; turn off all of the LED's on PORTC movlw D'10' movwf H'072' ; load up our third RAM with whatever decimal number is in the W register in the line above. This is how many times we'll call the utility delay. ; We control how long the delay is with this number because everytime we call the utility_delay, we add 0.05 seconds to the delay ; This current delay will be approximately 10 X 0.05 = 0.5 seconds. delay_off: call utility_delay ; every time we hit this line, we wait around for 0.05 seconds decfsz H'072', 1 ; every time we come back from the utility delay, we count down on our third register till we hit 0. Then we go back and start over. goto delay_off goto mainloop utility_delay: ; this subroutine is a utility delay that counts down from 255 255 times. That's a total count of 65025. It takes approximately 0.05 seconds at 16 MHz movlw D'255' movwf H'0070' ; load 255 into first register movlw D'255' movwf H'0071' ; load 255 into second register subloop: decfsz H'0070', 1 ; count down in first register till we hit 0 goto subloop movlw D'255' movwf H'0070' ; load 255 into first register again decfsz H'0071', 1 ; count down 1 on second register. If we're at 0, we've now gone through 255 loops of 255. Return back to the main program. goto subloop return end ; every program must have an end...at the end. :)