; ******************************************************************* ; Curso Pic Leccion 2 - "Blink" ; La primera leccion mostró como encenter un led ; Ahora veremos como hacerlo parpadear. Ciclos con delay son ; necesarios para encender y apagar el led, de tal forma que sea visible al ojo humano. #include __config _WDT_OFF & _PWRTE_ON & _LVP_ON & _CP_OFF & _XT_OSC cblock 0x20 Delay1 ; Define two file registers for the Delay2 ; delay loop endc org 0 Start bsf STATUS,RP0 ; select Register Page 1 bcf TRISC,0 ; make IO Pin B.0 an output bcf STATUS,RP0 ; back to Register Page 0 MainLoop bsf PORTC,0 ; turn on LED C0 OndelayLoop decfsz Delay1,f ; Waste time. goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec. ; call it a two-tenths of a second. bcf PORTC,0 ; Turn off LED C0 OffDelayLoop decfsz Delay1,f ; same delay as above goto OffDelayLoop decfsz Delay2,f goto OffDelayLoop goto MainLoop ; Do it again... end