; ******************************************************************* ; Curso Pic Leccion 3 - "Rotate" ; ; Continuando con la leccion 2 ahora haremos que se desplace el led encendido #include __config _WDT_OFF & _PWRTE_ON & _LVP_ON & _CP_OFF & _XT_OSC cblock 0x20 Delay1 ; Assign an address to label Delay1 Delay2 Display ; define a variable to hold the diplay endc org 0 Start bsf STATUS,RP0 ; select Register Page 1 clrf TRISC ; make IO PortC all output bcf STATUS,RP0 ; back to Register Page 0 movlw 0x08 movwf Display MainLoop movf Display,w ; Copy the display to the LEDs movwf PORTC 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 STATUS,C ; ensure the carry bit is clear rrf Display,f btfsc STATUS,C ; Did the bit rotate into the carry? bsf Display,3 ; yes, put it into bit 3. goto MainLoop end ; Como se habrá observado, solo se utilizaron 4 salidas del puerto C ; Modifique el programa para que se puedan utilizar las 8 salidas del puerto C ; Tip, revise el valor de la variable Display.