View previous topic :: View next topic |
Author |
Message |
GSFC PIC
Joined: 05 Apr 2005 Posts: 8
|
Problem With 16F684 I/O |
Posted: Wed Oct 05, 2005 12:27 pm |
|
|
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
|
|
|
GSFC PIC
Joined: 05 Apr 2005 Posts: 8
|
Thanks Trietmey |
Posted: Fri Oct 07, 2005 12:51 pm |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Fri Oct 07, 2005 1:53 pm |
|
|
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
|
|
Posted: Fri Oct 07, 2005 2:52 pm |
|
|
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)))) |
|
|
|