![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
weired A3, A4, A5 for 12f675 |
Posted: Thu Jul 29, 2004 12:50 pm |
|
|
I used the following program to test input and output, A0-A2 works fine, but I could not see any activities on A3, A4, A5 port. I just used them to output low and high to led to see the result, no response for them. I tried pull up and down these three port, but nothing happened.
Code: |
#if defined(__PCM__)
#include <12F675.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock=4000000)
//#use rs232(baud=9600, parity=N, BITS=8, xmit=PIN_A5,RCV=PIN_A4)
#byte CMCON = 0x19
void main()
{
int8 val1,val2;
CMCON = 7; // Comparators off
set_tris_a(0b00000101);
setup_adc_ports(sAN0|sAN2);
setup_adc( ADC_CLOCK_INTERNAL );
while(1) {
set_adc_channel( 2 ); //A2 as ADC
delay_us(50);
val2 = Read_ADC();
set_adc_channel( 0 ); //A0 as ADC
delay_us(50);
val1=read_adc();
if((val1>146) && (val2>146))
{
output_High(PIN_A1);
delay_ms(100);
output_low(PIN_A1);
delay_ms(100);
}
if((val1>146) && (val2<146))
{
output_high(PIN_A5);
delay_ms(100);
output_low(PIN_A5);
delay_ms(100);
}
if((val1<146) && (val2>146))
{
output_high(PIN_A3);
delay_ms(100);
output_low(PIN_A3);
delay_ms(100);
}
if((val1<146) && (val2<146))
{
output_high(PIN_A4);
delay_ms(100);
output_low(PIN_A4);
delay_ms(100);
}
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jul 29, 2004 12:55 pm |
|
|
I also could not used them as ADC port for input. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Jul 29, 2004 2:37 pm |
|
|
young wrote: | I also could not used them as ADC port for input. |
First obvious comment. A3, is _only_ an input pin. It cannot function as an output on this chip....
Second thing is that if val2, never gets below 146, A4, and A5, will never operate. I'd suspect there is something wrong in the connections round this pin.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jul 29, 2004 2:41 pm |
|
|
As you pointed out A3 is always a input pin, I just found it out also from the data sheet. regarding the A4, A5, I tried val1 and val2 to control the A1 pin, it works fine. |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 29, 2004 2:51 pm |
|
|
Quote: | As you pointed out A3 is always a input pin, I just found it out also from the data sheet. regarding the A4, A5, I tried val1 and val2 to control the A1 pin, it works fine. |
See your previous post and you will find someone already pointed that out.
http://www.ccsinfo.com/forum/viewtopic.php?t=20049 |
|
![](templates/subSilver/images/spacer.gif) |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jul 29, 2004 3:03 pm |
|
|
I even tried this it still does not work, I already set comparators off, I can not use set_comparators(NC_NC_NC_NC); compiler said it does not being defined, however the 12f675.h has this functions.
Code: |
#if defined(__PCM__)
#include <12F675.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock=4000000)
#byte CMCON = 0x19
void main()
{
CMCON = 7; // Comparators off
while(1)
{
output_high(PIN_A4);
delay_ms(100);
output_high(PIN_A5);
delay_ms(100);
output_low(PIN_A4);
delay_ms(100);
output_low(PIN_A5);
delay_ms(100);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jul 29, 2004 3:13 pm |
|
|
typo: it is setup_comparators() not being defined more weired? |
|
![](templates/subSilver/images/spacer.gif) |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jul 29, 2004 3:48 pm |
|
|
Any specific directions? I tried this also
Code: |
while(1)
{
output_high(PIN_A0);
delay_ms(100);
output_high(PIN_A1);
delay_ms(100);
output_high(PIN_A2);
delay_ms(100);
output_high(PIN_A4);
delay_ms(100);
output_high(PIN_A5);
delay_ms(100);
output_low(PIN_A0);
delay_ms(100);
output_low(PIN_A1);
delay_ms(100);
output_low(PIN_A2);
delay_ms(100);
output_low(PIN_A4);
delay_ms(100);
output_low(PIN_A5);
delay_ms(100);
}
|
A0-A2 is working, A4,A5 does not? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Jul 30, 2004 2:18 am |
|
|
young wrote: | Any specific directions? I tried this also
Code: |
while(1)
{
output_high(PIN_A0);
delay_ms(100);
output_high(PIN_A1);
delay_ms(100);
output_high(PIN_A2);
delay_ms(100);
output_high(PIN_A4);
delay_ms(100);
output_high(PIN_A5);
delay_ms(100);
output_low(PIN_A0);
delay_ms(100);
output_low(PIN_A1);
delay_ms(100);
output_low(PIN_A2);
delay_ms(100);
output_low(PIN_A4);
delay_ms(100);
output_low(PIN_A5);
delay_ms(100);
}
|
A0-A2 is working, A4,A5 does not? |
Take the chip out, and verify that you can pull the signals high with a resistor.
How old is the compiler?. The _setup_comparator_ (note no 's') function works fine for me, and everything you show should work.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Jul 30, 2004 5:52 am |
|
|
Thank you, you are right, I put 's' at the end of the function, I correct it. setup_comparator() now is working, but A4-A5 is still not working> |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Jul 30, 2004 6:21 am |
|
|
OK, I found out, the board I am using just connected A0-A2 pin with led, not the A4-A5 of 12f675, Stuip board weiring caused me one day to find out! I found out when I am using easy2 board, I have to face some challanges like these, not once, several times!!! |
|
![](templates/subSilver/images/spacer.gif) |
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Fri Jul 30, 2004 1:39 pm |
|
|
sure, blame the arrow ![Cool](images/smiles/icon_cool.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|