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

Problem With 16F684 I/O

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



Joined: 05 Apr 2005
Posts: 8

View user's profile Send private message

Problem With 16F684 I/O
PostPosted: Wed Oct 05, 2005 12:27 pm     Reply with quote

To all PIC masters !

I am using PIC 16F684 with CCS C compiler version 3.2222. I just try to flash on/off all general purpose I/O lines on this device via LEDs. So far, only LEDs RC0 through RC5 and RA0, RA1, RA2 are flashing. LEDs RA3, RA4 and RA5 are doing nothing. What have I done wrong ?. I tried to set port A to all outputs by using set_tris_a(0x00), but nothing seem working properly. Please advise. This is my program

#include <16F684.h>
#use delay(clock=4000000)
#fuses nowdt,hs
void main()
{
do
{
output_A(0xff);
output_C(0xff);
delay_ms(300);
output_A(0x00);
output_C(0x00);
delay_ms(300);
}while(true);
}
treitmey



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

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

PostPosted: Wed Oct 05, 2005 1:03 pm     Reply with quote

Is the RA3,RA4,RA5 open collector, analog or anything else unusual.
http://ww1.microchip.com/downloads/en/DeviceDoc/41202C.pdf
around page 40
looks to me that RA3 is input only, and RA4 and 5 are AD and crystal resonator. Are these turned off?
GSFC PIC



Joined: 05 Apr 2005
Posts: 8

View user's profile Send private message

Thanks Trietmey
PostPosted: Fri Oct 07, 2005 12:51 pm     Reply with quote

Trietmey !

Thanks a bunch for helping me out with this problem. After went through the spec sheet, RA3 is an Input only and RA4 and RA5 are OSC1/CLKIN and OSC2/CLKOUT respectively. Now, please bare with me for my lacking of understanding in PIC design. Is it true that for every PIC you must use some source of clock input ranging from DC to 20 Mhz, right ?. In my PIC circuit, I used 4 Mhz clock which connected to RA4 and RA5 as my OSCs inputs. Do I lose the use of RA4 and RA5 as general purpose I/O since I connect my clock to these pins ? indeed , if that is true then why Micro Chip assigned clock and I/O functions on the same pins ??? ( I' am so confusing on this issue, please expalin). Just assume that everything is OK, then how do I turn off or reassign function from the following pins to make them become general purpose I/O only using CCS C compiler
dyeatman



Joined: 06 Sep 2003
Posts: 1931
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Oct 07, 2005 1:53 pm     Reply with quote

To enable the pins for I/O you need to use the internal OSC. Try these fuses:

Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                //Internal RC Osc, no CLKOUT
#FUSES NOMCLR                  //Master Clear pin disabled


As stated previously RA3 will still be an input only...
treitmey



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

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

PostPosted: Fri Oct 07, 2005 2:52 pm     Reply with quote

As dyeatman has said.....

You can use the both pins as I/O IF YOU USE INTERNAL oscilator.

OR

You can use one pin osc2 as I/O and put a clock driver on osc1.

OR

Neigher pin is used as I/O because
Both will be used with an external crystal/cap setup.

see how microchip does it.
page 19
Y1 is crystal/cap
Y2 is a clock generator
http://ww1.microchip.com/downloads/en/DeviceDoc/51275b.pdf
((((Y3 by the way is for a real-time-clock))))
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