lesson 4 bit manipulation need 8 leds attached to porta:0-7
These four routines [below] march a single lit led across the eight pins of porta from a0 to a7 when inserted in the shell provided.
try each, which is the best do you think
one of them could have "issues" @ 64mhz. which one? and why?
can you reverse the direction of the march for each one ?
can you light up the leds and march a single unlit led across the eight pins of porta from a0 to a7 ?
i.
PORTA.0=1
WHILE PORTA
PAUSE 200
PORTA=PORTA<<1
WEND
ii.
PORTA.0=1
WHILE PORTA
PAUSE 200
PORTA=PORTA*2
WEND
iii.
PORTA.0=1
PAUSE 200
PORTA.0=0
PORTA.1=1
PAUSE 200
PORTA.1=0
PORTA.2=1
PAUSE 200
PORTA.2=0
PORTA.3=1
PAUSE 200
PORTA.3=0
PORTA.4=1
PAUSE 200
PORTA.4=0
PORTA.5=1
PAUSE 200
PORTA.5=0
PORTA.6=1
PAUSE 200
PORTA.6=0
PORTA.7=1
PAUSE 200
PORTA.7=0
iv.
PORTA=1
PAUSE 200
PORTA=2
PAUSE 200
PORTA=4
PAUSE 200
PORTA=8
PAUSE 200
PORTA=16
PAUSE 200
PORTA=32
PAUSE 200
PORTA=64
PAUSE 200
PORTA=128
PAUSE 200
PORTA=0
Code:
#CONFIG CONFIG FOSC=INTIO67, PLLCFG=OFF, PRICLKEN=OFF, FCMEN=OFF, IESO=OFF
CONFIG PWRTEN=OFF, BOREN=SBORDIS, BORV=190, WDTEN=ON, WDTPS=32768
CONFIG CCP2MX=PORTC1, PBADEN=OFF, CCP3MX=PORTB5, HFOFST=ON, T3CMX=PORTC0
CONFIG P2BMX=PORTB5, MCLRE=EXTMCLR, STVREN=ON, LVP=OFF, XINST=OFF, DEBUG=OFF
CONFIG CP0=OFF, CP1=OFF, CP2=OFF, CP3=OFF, CPB=OFF, CPD=OFF, WRT0=OFF
CONFIG WRT1=OFF, WRT2=OFF, WRT3=OFF, WRTC=OFF, WRTB=OFF, WRTD=OFF, EBTR0=OFF
CONFIG EBTR1=OFF, EBTR2=OFF, EBTR3=OFF, EBTRB=OFF
#ENDCONFIG
define OSC 64
OSCCON = $70 ; 64Mhz
OSCTUNE.6 = 1 ; Enable 4x PLL
TRISA = NOT 17
ansela = ~ $FF
LOOPY:
;insert code here
PAUSE 3000
GOTO LOOPY
Bookmarks