16f872. config ports and serin question.


Closed Thread
Results 1 to 3 of 3
  1. #1
    kitcat's Avatar
    kitcat Guest

    Default 16f872. config ports and serin question.

    Hi there.
    I want to set up a 16f872 so that all ports are digital. I have had trouble with analogue inputs on a 14 pin package and disabled it with this:
    ANSEL = 0
    What configuration do I need to make all ports digital i/o/ports.

    Secondly. I am sending 2 bytes from a pc and I want to output these two bytes on portb and portc.

    Is it ok to simply do this:

    serin portb.2,6, mylowbyte
    serin portb.2,6, myhihgbyte
    portb = mylowbyte
    portc = myhighbyte

    AM I right in thinking that the pic will sit there doing nothing until it receives a character on the input pin? I am sending two bytes from my pc software every time someone pushes a foot pedal. Is there anything that I should know here/

  2. #2
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    According to the datasheet......
    ADCON1 = 7 ' Set all pins to digital , then use TRIS to set input or output

    As for serial output. Look at the manual for serout commands, this should get you what you need.

  3. #3
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hello Kitcat,

    On the 16F872 only Port A pins are analog or digital. The ADCON1=7 command sets PortA to all digital. If you are looking for serial operation, any pin on the chip can be used as a serial I/O pin. If you intend to use a hardware serial setup with a RS232 level shifter then you want to use RC.6 for Tx and RC.7 for Rx. I don't mean to sound like a broken record but you should go to microchip.com and download the datasheet on the 16F872 to get all the info you will need to work with this uP.

    BobK

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