Code:
;************* set up pattern data **********
Patt1 DATA 16,1,2,4,8,16,32,64,128,128,64,32,16,8,4,2,1
Patt2 DATA 8,129,66,36,24,24,36,66,129
Patt3 DATA 16,1,3,2,6,4,12,8,24,16,48,32,96,64,192,128,0
Patt4 DATA 16,1,128,2,64,4,32,8,16,8,32,4,64,2,128,1,0
Patt5 DATA 12,24,60,126,255,231,195,129,0,129,195,231,255
Patt6 DATA 13,1,2,4,8,17,34,68,136,16,32,64,128,0
Patt7 DATA 8,128,64,32,16,8,4,2,1
;************* set up PIC ********************
ADCON1=$0F
CMCON = 7 ' Digital inputs
CCP1CON = 0 ' PWM off
TRISA=%11100111 'set PORTA as all input apart from A3 & A4
TRISB=%00000000 'set PORTB as all output
PORTB=0
;************* set up variables ***************
ByteA var byte
D var byte
scale var byte ;used in the POT command
Scale = 254
steps var byte
swcount var byte
swcount=3 ; set to 3 for testing only
N var byte
;**************** main program ********************
main:
if swcount = 1 then read Patt1, steps ;read the first value in data string patt1 and place it in steps
if swcount = 2 then read Patt2, steps
If swcount = 3 then read Patt3, steps
if swcount = 4 then read Patt4, steps
if swcount = 5 then read Patt5, steps
If swcount = 6 then read Patt6, steps
If swcount = 7 then Read patt7, steps
n = swcount
Pot PORTA.1,scale,D ;used to read value from 10k pot
for bytea=0 to steps
PORTB=DCD patt,n
PAUSE D
NEXT
goto main
The other question I have, is on a 16F628A the datasheet shows the program memory (flash words) as 2048, data memory as 224 bytes SRAM and 128 EEPROM bytes. However the Datasheet for the 16F873A shows Program memory as 7.2K bytes / 4096 single word instructions. Can someone advise why / what is meant by the two entries for the '873A's program memory, and if it's different to the '628A's memory ?
Bookmarks