CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

f877 port D input problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
minemind



Joined: 11 Apr 2005
Posts: 3

View user's profile Send private message Yahoo Messenger

f877 port D input problem
PostPosted: Mon Apr 11, 2005 9:09 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 12, 2005 2:29 am     Reply with quote

Quote:
set_tris_d(0xff);


Did you also set up port A for output somewhere in your code?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

try this
PostPosted: Tue Apr 12, 2005 8:01 am     Reply with quote

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

View user's profile Send private message Yahoo Messenger

Thanks
PostPosted: Tue Apr 12, 2005 7:29 pm     Reply with quote

You all help me a lot.
TQ.

Emi
_________________
minemind
minemind



Joined: 11 Apr 2005
Posts: 3

View user's profile Send private message Yahoo Messenger

Thanks
PostPosted: Tue Apr 12, 2005 7:29 pm     Reply with quote

You all help me a lot.
TQ.

Emi
_________________
minemind
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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