How do I configure the PIC16F737?


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Question How do I configure the PIC16F737?

    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

  2. #2
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default My 2 cents!

    Welcome.
    I lean on this forum myself quite often. I've found if you're willing to do your own legwork that the people here are more than willing to point you in the right direction.
    As far as your program goes the one thing that jumped out at me was the way you are setting up the TRIS registers. Here is how I set them up for a program I'm working on now.
    Code:
    PORTA = %00000000       'Set all outputs to 0 (off)
        TRISA = %00000000       'Set PORTA RA0-RA5 to outputs  
        PORTB = %00000000       'Set all outputs to 0 (off)
        TRISB = %01000011       'Set PORTB to all output except RB0/INT , RB1/data in, RB6 on/off switch
    	PORTC = %00000000       'Set all outputs to 0 (off)
    	TRISC = %00000000       'Set PORTC to all output
    Hope this helps some...
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default May have hurt it.

    Thanks for the input ronjodu,
    I made the changes as recommended but still got the same "no response" from RB3-RB5, RA6-RA7. I'm thinking I hurt my only device when I first wired it up with 5V to pin 28 (but no GND) instead of pin 20, was to excited and in a hurry. Gonna order some more in the mean time.

  4. #4
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default More help.

    I didn't mean for you to cut and paste what I posted. Did you change the ports to accomodate your aplication? In other words did you set the bits in each port for the inputs you are using and clear the bits for the outputs you are using?

    The other thing jumping out at me is between your code for pin 23 and 24 you have the "goto loop" statement sending the pprogram back to the beginning.

    That statement should be at the end of the program I believe.

    As far as killing the pic, they are fairly resilient. If all you did is put 5 volts on an I/O pin you probably didn't damage it.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  5. #5
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Red face My hair is growing back! You Saved Me!

    Quote Originally Posted by ronjodu View Post
    I didn't mean for you to cut and paste what I posted. Did you change the ports to accomodate your aplication? In other words did you set the bits in each port for the inputs you are using and clear the bits for the outputs you are using?

    The other thing jumping out at me is between your code for pin 23 and 24 you have the "goto loop" statement sending the pprogram back to the beginning.

    That statement should be at the end of the program I believe.

    As far as killing the pic, they are fairly resilient. If all you did is put 5 volts on an I/O pin you probably didn't damage it.
    I understood what you are doing by making sure the ports are first turned OFF then setting them as needed. Thanks
    "goto loop" statement , THAT WAS IT!! Thanks alot. Now all the ports are responding to my configuration so now I can move on to the next part of the learning curve.

  6. #6
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default I'm as happy as you.

    With all the help I've gotten in this forum It's really exciting to give back a little help and have it mean something. Good Luck..
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

Similar Threads

  1. 16F684 Basic Functionality
    By munromh in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 30th September 2009, 20:28
  2. how to configure multi click in keypad
    By ilham M in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th May 2009, 19:56
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31
  4. How to configure the clock??!!
    By sergio.elias in forum Serial
    Replies: 3
    Last Post: - 21st June 2006, 04:48
  5. max7219 and pic16f627
    By helenevans in forum mel PIC BASIC
    Replies: 9
    Last Post: - 25th August 2005, 16:10

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts