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

weired A3, A4, A5 for 12f675

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



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

weired A3, A4, A5 for 12f675
PostPosted: Thu Jul 29, 2004 12:50 pm     Reply with quote

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);
   } 
 
 
   }
}
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 12:55 pm     Reply with quote

I also could not used them as ADC port for input.
Ttelmah
Guest







PostPosted: Thu Jul 29, 2004 2:37 pm     Reply with quote

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
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 2:41 pm     Reply with 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.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Thu Jul 29, 2004 2:51 pm     Reply with quote

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
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 3:03 pm     Reply with quote

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);

}

}
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 3:13 pm     Reply with quote

typo: it is setup_comparators() not being defined more weired?
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 29, 2004 3:48 pm     Reply with quote

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?
Ttelmah
Guest







PostPosted: Fri Jul 30, 2004 2:18 am     Reply with quote

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
Guest








PostPosted: Fri Jul 30, 2004 5:52 am     Reply with quote

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>
Guest








PostPosted: Fri Jul 30, 2004 6:21 am     Reply with quote

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!!!
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Fri Jul 30, 2004 1:39 pm     Reply with quote

sure, blame the arrow Cool
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