Hello folks with the most,
Being a total newbie at this, please excuse my almost total ignorance with this question.
I've been trying to configure the 16F737 for all the I/O's needed on my project that will use
1. RB0-RB5, RA6-RA7 as digital inputs and AN0-AN1 as analog inputs for pots.
2. RC0-RC7 as digital outputs. Seems to be working okay.
3. INT OSC at 4MHz with no outputs. Seems to working okay.
Get ready to laugh...
As you can see by my "test" program (copied and pasted). The configuration is doing something funny because the TRISB has to be changed occasionally to =11 just so RB1 is recognized or it measures about 75 ohms to GND!
The program was written the best way I know how (for the moment) to test various outputs, connected to LED's for visual confirmation, vs. inputs using binary or HEX.
I'm not asking that my work be done for me but just been looking for an outline on configuring these fantastic components so that I can use them properly. I've already been told "somewhere else" to "read the data sheet because it's all in there and it's very simple". I read and read to no avail, I think he was having a bad day...
Thanks for the help,
'************************************************* **************
'* Notes : Using the PIC16F737, this program will provide 8 pulsed outputs
'* : from decoding 8 digital inputs and 2 variable analog
'* : inputs. The output pulse time will be adjustable from 20ms to 120ms with the
'* : two pots.
'* :
'* :
'************************************************* ***************
@ DEVICE PIC16F737, INTRC_OSC_NOCLKOUT, WDT_ON, PROTECT_OFF, MCLR_ON
CLRW ' I think it clears it's throat
OSCCON = %01101000 ' Oscillator set to 4MHz, RA6 & RA7 as I/O
ADCON1 = %00001101 ' Disable all but AN0 & AN1 analog inputs
TRISA = 1 ' Sets PORTA pins as inputs
TRISB = 11 ' Sets PORTB pins as inputs
TRISC = 0 ' Sets PORTC pins as outputs
Pause 200 ' Keep outputs from pulsing at startup
loop:
' Pin 21 goes HI then pins 11 & 13 go HI
if PORTB.0 = 1 THEN
'PORTC = %00000101 ' works!
PORTC = $5 ' works!
else
PORTC = $00
ENDIF
' Pin 22 goes HI then pins 12 & 14 go HI
if PORTB.1 = 1 Then
'PORTC = %00001010 ' works!
PORTC = $A ' works!
ELSE
PORTC = $00
ENDIF
' Pin 23 goes Hi then pins 16 & 18 go HI
if PORTB.2 = 1 Then
'PORTC = %10100000 ' works!
PORTC = $A0 ' works!
ELSE
PORTC = $00
ENDIF
goto loop
' Pin 24 goes HI then pins 15 & 17 go HI
if PORTB.3 = 1 Then
'PORTC = %01010000 ' no response
PORTC = $50 ' no response
ELSE
PORTC = $00
ENDIF
' Pin 25 goes HI then pins 13 & 18 go HI
if PORTB.4 = 1 Then
'PORTC = %10000100 ' no response
PORTC = $84 ' no response
ELSE
PORTC = $00
ENDIF
' Pin 26 goes HI then pins 11 & 16 go HI
if PORTB.5 = 1 Then
'PORTC = %00100001 ' no response
PORTC = $21 ' no response
ELSE
PORTC = $00
ENDIF
' Pin 10 goes HI then pins 11, 13, 16, 18 go HI
if PORTA.6 = 1 Then
'PORTC = %10100101 ' no response
PORTC = $A5 ' no response
ELSE
PORTC = $00
ENDIF
' Pin 9 goes HI then pins 12, 14, 15, 17 go HI
if PORTA.7 = 1 Then
'PORTC = %01011010 ' no response
PORTC = $5A ' no response
ELSE
PORTC = $00
ENDIF
End
Bookmarks