16F877a PORTA ADC and digital help


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Sure.

    TRISA = %00100000

    Sets PORTA.5 as an input pin and all others in PORTA as output pin.

    There is something here to pay attention for.
    Although PORTA is 6-bit (RA0 to RA5), TRIS register uses 8-bit (0 to 7).
    In this case, only right bits are considered. Thus, Bit7 and Bit6 in TRISA register are ignored ; whether they are 1 or 0 it won't matter.


    TRISE = %00000000

    Sets PORTE.0, PORTE.1 and PORTE.2 as output pins.

    Also here, PORTE is only 3-bit (RE0 to RE2). So that, all other bits in TRISE register will be ignored.


    You can also set an individual bit by,

    TRISE.0=0

    Sets RE0 as an output pin.

    or

    TRISE.0=1 sets RE0 as an input pin.


    If you set a pin as analog, it must be an input pin.


    For Internal Weak Pull-ups, there is a bit in OPTION_REG register.
    Bit7.

    OPTION_REG.7 is PORTB Pull-up Enable bit

    OPTION_REG.7 = 1
    PORTB pull-ups are disabled.

    OPTION_REG.7 = 0
    PORTB pull-ups are enabled by individual port latch values.

    Once you set this bit as 0 then you can have weak pull ups on PORTB pins that were set to be input pins beforehand.

    -----------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Ok fine,

    Understood, so PORTB has only the weak pull-up feature ?

    another question concerning HSERIN

    I'm using a 16f877 with max 232 at 4mhz

    I'm having problems reading multiple variables in 1 serin string
    It works, but after some times it hangs so I think there is a buffer overflow
    What worries me is that when i measure with an osciloscope, there are pulses on portc.7 the UART RX even with no max232 chip connected ???

    Here is a part of the code:

    DEFINE HSER_RCSTA 90h ' enable serial port,
    ' enable continuous receive
    '
    define HSER_TXSTA 24h ' enable transmit,
    ' BRGH=1
    '
    define HSER_SPBRG 103 ' set baudrate to 2400
    DEFINE HSER_CLOERR 1 ' automatic clear overrun error

    TRISB = %00000000
    'OPTION_REG.7 = 0 ' Enable PORTB pullups
    TRISC = %10000000
    TRISD = %00001111
    TRISE = %000

    loop:
    Hserin 500,LCD,[wait ("TAR"),dec3 var1,wait ("ANT"),DEC3 var2,wait ("AUX"),DEC3 var3,wait ("EXT"),DEC3 var4]


    LCD:
    pause 10
    Lcdout $fe, 1 ' Clear screen

    Lcdout "VAR1: ",#VAR1," VAR2: ",#var2

    Lcdout $fe, $c0, "VAR3: ",#VAR3," VAR4:",#VAR4

    Goto loop

    Any Idea ?

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi RF,

    I do not have much experience in serin/serout commands.

    I may mislead you with some incorrect or never tried advices.

    But, at first look, I am not sure whether you can use more then one "WAIT" in one serin command or not.

    I believe another member with valuable and reliable Serin/Serout experiences will respond.

    ----------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Replies: 5
    Last Post: - 16th October 2009, 18:29
  2. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  3. 16F877A problem: "coupled" digital values
    By Lupo83 in forum General
    Replies: 16
    Last Post: - 4th December 2007, 12:46
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. Problem with ADC
    By savnik in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 25th November 2006, 07:37

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