• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16F887 can't detect input

Status
Not open for further replies.

jkashiwada

New Member
Hello All,

I've switched from assembly to C using MikroC. I still wish only to display a message to my LCD if an input pin goes high. I don't have my code with me but it is very simple. Under main i do the following

ANSEL = 0;
ANSELH = 0;

PORTD = 0; // clear port D
TRISD = 0xFF; // Set port D as input

while (1) {
if (PORTD,0 == 0) {
Lcd_Out(1,1,"RD0 is low");
}else{
Lcd_Out(1,1,"RD0 is high");
}
}

when i run this the lcd only says "RD0 is low" regardless of the input i give. Is there some register or setting, or configuration bit i must set or not set? Any advice would be greatly appreciated.

Thanks =)
Jake
 

rahulcet

New Member
Try PortB as input. i too have had trouble with using portD as input sometimes. Dunno why. Jus try. Good Lcuk mate
 

rahulcet

New Member
Mikro C is not MPLAB compatible
if (PORTD,0 == 0) would become
if (PORTDbits.RD0==0) in C18. and i do not know, if there are library functions for lcd
 

jkashiwada

New Member
wow that was quick.... =)

I've tried PORTB as well...I ended up on PORTD because according to the datasheet, RD0:RD4 are I/O only. The LCD works fine and was initialized on PORTC earlier in my code that I have not shown (Lcd_Init(&PORTC) something like this)

Anyways... I was hoping there was some register or setting I was unaware of to check? Any suggestions off top of your head?

Thanks =)
Jake
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top