Thompson, Michael wrote: > > Hi, everyone! > > I finally built a programmer for the 16C84 (the AN589 version with > the Andrew Errington software) but now have to figure out how to use > the damned thing. I've written some simple programs to turn on and off > a couple of LEDs but now want to read some switches. Would someone > mind sending me a sample prorgam to read, say, four bits/switches and > send the four switch positions to four LEDs? I know this seems > ridiculously simple but I'm unsure of the paging thing with the FSRs. > Once I can do this I can figure out the rest (I've used the 8031 and > a couple others for a long time so microcontrollers aren't exactly > new to me). > > Thanks to anyone who will take the time to do this for me. > > Mike Thompson Hi try this one novice to another PORTA equ 5 ; I/O register F5 PORTB equ 6 ; I/O register F6 TRISA equ 85 ; I/O direction register F85 TRISB equ 86 ; I/O direction register F86 STATUS equ 3 ; STATUS register F3 RPO equ 5 ; page select bit DELAY equ 0Ch ; inner delay loop X_DELAY equ 0dh ; outer delay loop ;FIRST initialize porta as inputs & portb as outputs. LOOP BTFSS PORTA,0 ; if portb bit zero is high skip next instructio n GOTO BUTTON_1 ; jump directly to the instruction after the lab el BUTTON_1 BTFSS PORTA,1 ; if portb bit one is high skip next instruction GOTO BUTTON_2 ; jump directly to the instruction after the lab el BUTTON_2 ;repeat as necessary..... GOTO LOOP ; back around again BUTTON_1 INCF PORTB,F ; make the output pins of port b count up in bin ary to 11111111 then 0 MOVLW 03h ; call delay with length of desired delay in W r egister CALL X_DELAY ; "" GOTO LOOP ; back around again BUTTON_2 CLRF PORTB ; sets portb pins LOW MOVLW 03h ; call delay with length of desired delay in W d elay CALL X_DELAY ; "" GOTO LOOP ; back around again ;******* a delay of 'W' * Inner Loop subroutine X_DELAY MOVWF X_DELAY ; put value of w register into x_delay variable (GPR) MOVLW D'10' ; constant number of loops ( inner ) pick a number that works for you X_DELAY_LOOP MOVWF DELAY DELAY_LOOP DECFSZ DELAY, F ; inner loop GOTO DELAY_LOOP ; "" DECFSZ X_DELAY,F ; outer loop GOTO X_DELAY_LOOP ; "" RETURN END ; you will need a variable delay in lots of things and if you omit it here the port pins will increment to fast for you to see and will appear all on dimly or off.also I assume you have the code to initialize the ports. Have fun ! Tony M. oh yeah not responsible for ensuing addictions or misspellings 8)