I/O ports in PIC18f87J90

Thread Starter

RG23

Joined Dec 6, 2010
304
I am using PICDEM LCD2 development board with PIC18f87J90 controller

I intend to use only two inputs for up and down counter
I defined the ports as follows:

clrf PORTB
movlw 0xC0
movwf TRISB

for using PORTB 7 and 6 as inputs

When I make these changes in my program I am not executing up and down correctly

I am using LUMEX LCD where supply voltage for logic is 5V.

I provide 5V for display VDD using voltage regulator

But when I check the voltage on PORTS B 6 and 5 it is 2.5V and 1.78V respectively

Also Vcc on the board for PIC18f87J90 is 3.3V

If anyone has an idea please let me know

Thanks
 
Last edited:

Thread Starter

RG23

Joined Dec 6, 2010
304
Switches are already connected to Port B 7 and 6 on the development board.

Hence I configure them as inputs

I hope I made my question clear
 

PRS

Joined Aug 24, 2008
989
I am using PICDEM LCD2 development board with PIC18f87J90 controller

I intend to use only two inputs for up and down counter
I defined the ports as follows:

clrf PORTB
movlw 0xC0
movwf TRISB

for using PORTB 7 and 6 as inputs
I am a novice at PICs, and so I don't want to offend you by calling your attention to things you probably already know. But did you zero ANSEL such as to make the pins you are using digital?


When I make these changes in my program I am not executing up and down correctly

I am using LUMEX LCD where supply voltage for logic is 5V.
Is your LCD using TTL? If so, you need a ucontroller with 5 volt I/O.

I provide 5V for display VDD using voltage regulator

But when I check the voltage on PORTS B 6 and 5 it is 2.5V and 1.78V respectively
If you are supplying the PIC with 3.3 volts, it only has 3.3 volts available on its I/O pins.

Also Vcc on the board for PIC18f87J90 is 3.3V

If anyone has an idea please let me know

Thanks
I hope something I said helped.
 
Last edited:

Thread Starter

RG23

Joined Dec 6, 2010
304
I got the up and down functions working using the switches on the development board but there is something strange happening out there

Actually there are four switches connnected to PORTB pins 6 & 7 and to PORTA pins 6 & 7 on the board

I am using PORTB,6 for down and PORTA,6 for up

I declare the ports as follows:

clrf PORTA
movlw 0x40
movwf TRISA

clrf PORTB
movlw 0x40
movwf TRISB

When I define the ports as above the up and down buttons do not work

In place of 0x40 for TRISB when I put 0xC9 they function as required

I don't understand the reason behind it

If anyone has an idea please let me know

Thanks
 

Thread Starter

RG23

Joined Dec 6, 2010
304
Also when I try to configure PORTA,7 as up button switch and make the necessary changes to TRISA, it doesn't work

Can anyone help me out in that too?

Thanks
 

thatoneguy

Joined Feb 19, 2009
6,359
Your change, movlw 0x40 ("b0100 0000"), is setting Rx6 ONLY as input.

When the program uses 0xC9, the bits on the port are b1100 1001

(I added spaces between each nybble above for easier reading of Hex digits)

Since you say the counter works with 0xC9, and doesn't with 0x40, even though both have Rx6 set as input, take a look at the board schematic as well as the rest of your code to see what all connections and requirements are.

Depending on what is connected, you may be disabling inputs required by the program/hardware.

Since Rx6 is already set for input, why are you clearing the rest of the bits?

A good way to make sure a pin is set as you like without disturbing the port is to AND the bit you want set with the existing value.

As for the voltages, you will only get 3.3V out, since the J says it is a 3.3V uC. You can boost that output up to 5V with a transistor, though it would invert the output state.

Lastly, Look at the Datasheet first, to make sure there isn't an on chip peripheral already blocking that port from another use without configuration changes.
 
Top