Hello KD6OJI,
Since I have been working with PICs for awhile I think I might be able to get you started in the right direction. I am just starting to work with the 628 myself after doing some big work with 16F74's 877's and 18F452's. But they are all basically the same.
First on your PortA problem. The CMCON and TRIS settings looked okay but you have to convert analog inputs to digital. This is done with ADCON1=7.
That should take care of that part.
ADCON1 = 7
CMCON = 7
TRISA = %00001111
TRISB = %11110000
Next is the PortB snippet you posted. SW0 thru 3 are fine but your program will only have an output on the selected port pin as long as you are holding the switch at ground. I am, of course, assuming you have pull up resistors on the input pins or have enabled the weak pullups. Now, the SW's can only equal 0 or 1. This means either the switch is open or closed. With a pull up resistor in place and the switch in the open state the pin will = 1. With the switch closed the pin will = 0. "SW0 = 2" and "SW0 = 3" will never work in your case.
After setting up the pull up resistors try this code:
SCAN:
If SW0 = 1 then HIGH PB0:PAUSE 2000
ELSE
LOW PB0
ENDIF
If SW1 = 1 then HIGH PB1:PAUSE 2000
ELSE
LOW PB1
ENDIF
What this will do is if the switch is closed it will then turn PB0 on for 2 seconds then off if the switch is released. The same thing should happen with SW1.
This is just basic stuff but this is how I learned!
Let me know if I can help more. There are some great patient people on this site that will probably jump in also.
BobK
Bookmarks