Using an 18F4525 with PortA as inputs, RA2 and RA3 always 0

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
rknepp
Posts: 2
Joined: 08 Mar 2011 05:29

Using an 18F4525 with PortA as inputs, RA2 and RA3 always 0

#1 Post by rknepp » 08 Mar 2011 05:45

I am using an 18F4525 and I would like to use PortA as inputs. I am using an external osc, so pins RA6 and RA7 are allocated for that function. I have configured PortA to be all inputs, but when I read the port with logic 1 on the inputs, RA2 and RA3 always show 0. Can someone point out what I am doing wrong? Thank you.

Code: Select all

porta = %00000000
    adcon1 = %11111111  ' PortA - Set to digital
    cmcon = %00000111   ' Disable Comparators
    trisa = %11111111   ' PortA - All Inputs
    trisb = %00000000   ' PortB - All Outputs
     
statusloop: parm1 = porta
    portb = parm1
    goto statusloop
I have LEDs on all PortB pins and bits 0, 1, 4, & 5 follow the logic placed on the corresponding PortA pins. Bits 2 and 3 always show 0.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Using an 18F4525 with PortA as inputs, RA2 and RA3 alway

#2 Post by filip » 08 Mar 2011 10:30

Hi,

Please, first of all, this is a mikroC for PIC forum, not mikroBasic for PIC forum.
Second, you didn't provide the code that can be compiled, i.e. parm1 was not declared.
Third, when I declared the parm1 variable and tested this on EasyPIC6, the code worked just fine.

Which development board and compiler/compiler version are you using ?

Regards,
Filip.

BarryP
Posts: 517
Joined: 02 Apr 2007 03:57
Location: New Zealand

Re: Using an 18F4525 with PortA as inputs, RA2 and RA3 alway

#3 Post by BarryP » 11 Mar 2011 22:29

Hi
does it still play up if you replace portb = parm1 with LATB = parm1

rknepp
Posts: 2
Joined: 08 Mar 2011 05:29

Re: Using an 18F4525 with PortA as inputs, RA2 and RA3 alway

#4 Post by rknepp » 11 Mar 2011 23:09

Problem solved! The problem was with the "adcon1 = %11111111" statement. I should have used %11001111. What I had turned RA2 and RA3 into VREF- and VREF+. Thanks to all who helped consider my problem! :D

Post Reply

Return to “mikroBasic PRO for PIC General”