Using portb as inputs PIC goes crazy


Closed Thread
Results 1 to 2 of 2
  1. #1

    Default Using portb as inputs PIC goes crazy

    Hello Everyone. For the first time I tried using all 8 portb's as inputs to switches. The are all held low with a 47K resistor network. The switches all have a common +. When I attempt to use them as inputs, my PIC goes crazy. It activates when no buttons are pressed, and activates intermittently when buttons are pressed. When I duplicated everything and switched porta with portb, using porta as inputs and portb as the outputs as shown below, everything works perfectly. Any suggestions would be appreciated. Thank you.

    OSCCON = $60 'set int osc to 4mhz using PIC16LF818 at 3VDC
    adcon1 = 7 ' set inputs to digital
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
    TRISA = %11111111 'PORTA INPUT SWITCHES (THIS WORKS PERFECTLY)
    TRISB = %00000001 'ALL PORTB OUTPUTS EXCEPT RB0 (NEED HIGH IMPEDANCE STATE)
    PORTB = %00000000 'PORTB OUTPUTS LOW
    Pause 100 'SETTLE DOWN

    START:
    NAP 0
    IF PORTA.1 = 1 Then OFF1
    IF PORTA.0 = 1 Then ON1
    IF PORTA.7 = 1 Then OFF2
    IF PORTA.6 = 1 Then ON2
    IF PORTA.2 = 1 Then OFF3
    IF PORTA.3 = 1 Then ON3
    IF PORTA.4 = 1 Then OFF4
    IF PORTA.5 = 1 Then ON4
    GoTo START

  2. #2
    Join Date
    Oct 2005
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Not sure I understand your circuit. One end of 47k resistor at GND, other end at Portb.x. One end of switch to portb.x, other end to +5. If this is it, it would seem that you could get floating voltage at portb pin. I believe a more common circuit would be resistor between +5 and portb as pullup, switch between portb and ground.

    I use portb for inputs on 16F876A with no problems.

    Others with more expertise feel free to correct me.

Similar Threads

  1. My PIC program won't work! Plz Help?!
    By beckyzammi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 4th March 2010, 18:26
  2. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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