+ Reply to Thread
Results 1 to 8 of 8

Thread: reading ports...

  1. #1
    me-electro Newbie
    Join Date
    Dec 2003
    Posts
    2

    Default reading ports...

    hi...

    I am a new member...

    I am doing a project using PIC16F877...

    and it's my first time using microcontrollers...

    I want to reed a value using this PIC and store it in a register inside...

    BUT... I don't know how...

    SO... can any one who know it help me...

    thaks alot...

    ops:


  2. #2
    ivancho Newbie
    Join Date
    Aug 2003
    Location
    Kansas
    Posts
    333

    Default

    You are going to need certain tools that are a must....
    You need to have a compiler..... assember, basic, C.... for the langague you chose to use.
    Then you are going to need a programmer like the EPIC..... so that you can download to the PIC the program you wrote

    Depending on each program you read and store ports pins....

    Good Luck

    Ivancho

  3. #3
    matasoft Newbie
    Join Date
    Mar 2003
    Location
    Athens, Greece
    Posts
    31

    Default

    You should go to http://www.microchip.com and download the PIC16F877 Datasheet. There you'll find valuable information about how the PIC works.

  4. #4
    me-electro Newbie
    Join Date
    Dec 2003
    Posts
    2

    Default

    hi again..

    thanx alot for answering me...

    all the things you all said I have already...

    BUT... I don't know how to write that program that will read the value and store it inside a register..... :shock: :?:

  5. #5
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,746

    Default

    Quote Originally Posted by me-electro
    hi again..

    thanx alot for answering me...

    all the things you all said I have already...

    BUT... I don't know how to write that program that will read the value and store it inside a register..... :shock: :?:
    You don't actually mention what sort of value it is you want to read, do you just mean reading a digital value from a port, or reading an analogue value. The first is extremely trivial, the simplest thing you could possibly do with a PIC - the second is pretty easy, but takes a few more lines.

    However, even in the first case, you will need to perform various setup procedures on the chip, these will be a great deal longer than the reading itself.

  6. #6
    ivancho Newbie
    Join Date
    Aug 2003
    Location
    Kansas
    Posts
    333

    Default

    For example in PICBASIC PRO all you do is define a variable and assign the port you want to read to that variable.... or simply read the register for the port.

    DIM myVar as Byte

    MyVAr = PortB ' Now myVar will have the value of RB7-RB0

    To be able to read inputs you havve to set the "direction" register, which is TRISB for PortB. Then you can assign which pin are inputs and which are outputs.

    What you need is a tutorial for the program you want to use...... PICBASIC is probably the easiest and quickest to learn.

    Good Luck

    Ivancho

  7. #7
    natbit Newbie
    Join Date
    Nov 2003
    Posts
    29

    Default

    me-electro u can never underestimate the info u get fron the datasheet, it seems easy to ignore at first, but eventually u will have to read some of it!

    The 16F877 has an 8 channel 10 bit S/A A/D convertor, should u require the reading of an analog signal, this should be used. If it is digital then u will need to understand how to either transmit or receive data from the various pins u choose and again, this goes back to reading the spec. sheet unfortunately...

  8. #8
    Mursel Newbie
    Join Date
    Dec 2003
    Posts
    1

    Default Re: reading ports...

    Quote Originally Posted by me-electro
    hi...

    I am a new member...

    I am doing a project using PIC16F877...

    and it's my first time using microcontrollers...

    I want to reed a value using this PIC and store it in a register inside...

    BUT... I don't know how...

    SO... can any one who know it help me...

    thaks alot...

    :oops:

+ Reply to Thread

Tags for this Thread