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 support@ccsinfo.com

inputs on 16F628

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



Joined: 11 Feb 2005
Posts: 11

View user's profile Send private message Send e-mail

inputs on 16F628
PostPosted: Mon Feb 21, 2005 8:17 pm     Reply with quote

Hi,

I am able to send a string via RS232, but when I try and read portA inputs and send the corresponding value I get garbage. I had a look at the data sheet and the inputs are designated as schmitt trigger inputs. What does this mean exactly. I have been using an 8 way dip switch which puts the supply voltage onto each of the Porta input pins. Perhaps this is wrong???

#include <16f628.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOMCLR
#use delay(clock=4000000) //clock rate in Hz
#use rs232(baud=9600, xmit=PIN_B2,rcv=PIN_B1)
int8 data;

void main() {
setup_uart (TRUE);
SET_TRIS_A( 0b11111111);
puts("Go");

while (TRUE) {

output_high(PIN_B4);
delay_ms(100);
output_low(PIN_B4);
delay_ms(500);
data = input_A();
putc(data);
delay_ms(100);

}

While(TRUE);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 21, 2005 8:43 pm     Reply with quote

Quote:
I have been using an 8 way dip switch which puts the supply
voltage onto each of the Porta input pins. Perhaps this is wrong???


The standard method is to put pull-up resistors on the PIC input pins,
and then connect each pin to a DIP switch section. The other side
of the DIP switches all go to ground.

Look at this schematic. He has 1K pullup resistors on RA0-RA2.
Each pin also goes to a switch, and the other side of the switches
go to ground. You don't need to use 1K. I would have used 4.7K
or 10K resistors.
http://www.vermontficks.org/pellets.gif

If you want extra safety, you can put a series resistor between
the PIC pin and the pullup and DIP switch. This prevents you
from accidently shorting the output driver of the PIC to ground,
in case you configure the pin as an output instead of an input,
as you intended. The 470 ohm series resistor limits the current
so the output driver won't be damaged. This is a good idea in
a board designed for students.
Look at the schematic on page 19 of the PicDem2-Plus manual
at the "40-pin Device", at pin RA4 to see this:
http://ww1.microchip.com/downloads/en/DeviceDoc/51275b.pdf
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