|
|
View previous topic :: View next topic |
Author |
Message |
minemind
Joined: 11 Apr 2005 Posts: 3
|
f877 port D input problem |
Posted: Mon Apr 11, 2005 9:09 pm |
|
|
Hi,
I'm having problem reading from port d. Port d use 10k pullups resistor and port a have led on each pins.
Am i missing something? I cannot read from port d. i'm using ccs ver2.686.
please help me since i've been working around for about quite some time. Below are some of the code.
#fuses HS, NOWDT, PUT, NOBROWNOUT, NOLVP, NOPROTECT
#USE FAST_IO(D)
#USE FAST_IO(E)
#byte portd=8
#byte porte=9
void main() {
char dBuff;
// i disable all interrupts
// and then. . .
disable_interrupts(GLOBAL);
port_b_pullups(FALSE); // disable pullups
setup_adc_ports(NO_ANALOGS); // disable analogs.
setup_psp(PSP_DISABLED); // disable psp
set_tris_d(0xff);
while (1) {
porta=portd; // send to porta, and this not working
dBuff=portd;
printf("%c", dBuff);
}
} _________________ minemind |
|
|
Sugiman
Joined: 12 Jan 2005 Posts: 15
|
|
Posted: Tue Apr 12, 2005 2:29 am |
|
|
Did you also set up port A for output somewhere in your code? |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
try this |
Posted: Tue Apr 12, 2005 8:01 am |
|
|
Code: | #include <16F877.h>
#device *=16
#use delay(clock=4000000)
#fuses HS,NOWDT,NOLVP,PROTECT,PUT,BROWNOUT
#use rs232(baud=9600,xmit=PIN_C4,INVERT,stream=DEBUG) // STDERR(same as DEBUG)
#use rs232(baud=1200,errors,xmit=PIN_C6,rcv=PIN_C7,parity=e,enable=PIN_C5,bits=8,stream=CIM)
#case
#zero_ram
#define VER_MAJOR 1
#define VER_MINOR 01
#use fast_io(D)
#byte relays=8 //16F877 port D is at 8
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
#USE FAST_IO(D)
#USE FAST_IO(E)
#byte porta=5
#byte portb=6
#byte portc=7
#byte portd=8
#byte porte=9
void main() {
char dBuff;
disable_interrupts(GLOBAL);
port_b_pullups(FALSE); // disable pullups
setup_adc_ports(NO_ANALOGS); // disable analogs.
setup_psp(PSP_DISABLED); // disable psp
set_tris_d(0xff);
set_tris_a(0x00);
while (1) {
porta=portd; // send to porta, and this not working
dBuff=portd;
printf("%c", dBuff);
}
}
|
|
|
|
minemind
Joined: 11 Apr 2005 Posts: 3
|
Thanks |
Posted: Tue Apr 12, 2005 7:29 pm |
|
|
You all help me a lot.
TQ.
Emi _________________ minemind |
|
|
minemind
Joined: 11 Apr 2005 Posts: 3
|
Thanks |
Posted: Tue Apr 12, 2005 7:29 pm |
|
|
You all help me a lot.
TQ.
Emi _________________ minemind |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|