I'm fairly new at this and I Can Not Read PortA ... (using a 16F877 & PicBasic Pro)


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    18

    Default I'm fairly new at this and I Can Not Read PortA ... (using a 16F877 & PicBasic Pro)

    Your help will be greatly appreciated!

    My Code is below.


    '************************************************* ***************
    '* Name : No Smoke *
    '* Author : Roddy Wayne *
    '* Notice : *
    '* : *
    '* Date : 10/23/2010 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************


    CLEAR ;always start with clear
    DEFINE OSC 4 ;define oscillator speed
    define DEBUG_REG PORTC
    DEFINE DEBUG_BIT 6
    define DEBUG_BAUD 2400
    DEFINE DEBUG_MODE 0
    DEFINE DEBUG_PACING 1000
    TRISA = %11111111 ;sets porta as inputs
    TRISB = %11111111 ;sets portb pins as inputs
    TRISC = %00000000 ;sets portc pins as outputs
    TRISD = %00000000 ;sets portd pins as outputs
    TRISE = %00000000 ;sets porte pins as outputs
    B0 Var Byte
    B2 Var Byte

    Start:
    B0 = PortB
    'Peek PortB, B0 'Read PortB, put answer in B0
    B2 = PortA
    'Peek PortA, B2 'Read PortA, put answer in B2
    Pause 25 'Short pause
    Debug 14, 1, "B0 Byte = ", BIN8 B0, " ", 13'Display Byte B0, & next line
    Debug "B2 Byte = ", Bin8 B2, " " 'Display Byte B2
    Pause 1000 'Wait a second
    Debug 1 'Send curser Home
    If (B0 = %00000000) Then Start 'If no input, go to Start
    If (B0 >=%00000001) Then LEDS 'If there's input, go to LEDS



    LEDS:

    High PortC.0 'Led On
    Pause 500 'Wait .5 second
    Low PortC.0 'Led Off
    Pause 1000 'Wait a second
    High PortC.7 'Beeper On
    Pause 500 'Wait .5 second
    Low PortC.7 'Beeper Off
    Pause 58000 'Wait about 1 minute (total)

    Goto Start
    End

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    By default portA is analog, to turn it into digital add: ADCON1 = 7 to your code before the tris setting.

    Cheers

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Apr 2009
    Posts
    18


    Did you find this post helpful? Yes | No

    Smile Thanks Al!

    Quote Originally Posted by aratti View Post
    By default portA is analog, to turn it into digital add: ADCON1 = 7 to your code before the tris setting.

    Cheers

    Al.
    Oops, I forgot about that!
    Thanks Al! All works as it should now.

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