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

PIN_A0 problem?

 
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

PIN_A0 problem?
PostPosted: Fri Nov 26, 2004 1:32 pm     Reply with quote

I have following program, but it just wired, because the led connected to PIN_A0 is always blink, which I believe that it should wait for me to click a letter 'a' and then blink, any idea why?
Code:

#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock = 4000000)   
#use rs232(baud=9600, parity=N, RCV=PIN_A2)

void main ()
{
  char a;
  setup_comparator(NC_NC_NC_NC);
  while(1)
     {
        output_high(PIN_A0);
        delay_ms(200);
        output_low(PIN_A0);
        delay_ms(200);   
        a=getc();
 
        if(a=='a')
        {
        output_high(PIN_A1);
        delay_ms(200);
        output_low(PIN_A1);
        delay_ms(200);
        }
       
      }
}

young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 1:57 pm     Reply with quote

When I click letter 'a', the led connected to PIN_A1 does not blink?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 1:58 pm     Reply with quote

While in iddle state, does PIN_A2 is stable HIGH ?

I guess getc() is getting a char != 'a'

Did you try to printf the value of variable a ?


HTH,
Humberto
djwallace



Joined: 26 Nov 2004
Posts: 10

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

PostPosted: Fri Nov 26, 2004 2:06 pm     Reply with quote

In your code,

if you just hit 'a' once on the keyboard, the LED on pinA1 should blink on and off once. The next time your loop goes around, it will hang at the line

a=getc();

until you hit a character. if you do not hit 'a' again, then it will not blink.
_________________
darryl
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 2:11 pm     Reply with quote

thank you, you are right? I measured the pin_a2, it is high connected to the max232 output pin, when I disconnected PIN_A2 to MAX232, it is low.
but how come it become a high. the connection I used for a long time, it works just fine, I did not change anything, even move wires.

when I printf out the a, I click on letter 'a', letter 'X' was returm, when I click on the other, different letter or no letter return, what is wrong?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 3:01 pm     Reply with quote

Quote:

thank you, you are right? I measured the pin_a2, it is high connected to the max232 output pin, when I disconnected PIN_A2 to MAX232, it is low.
but how come it become a high. the connection I used for a long time, it works just fine, I did not change anything, even move wires.

It is right. Iddle state of MAX232 rcv pin must be HIGH in TTL side.

Does the PC COM settings: 9600,N,8,1 ?



Humberto
Guest








PostPosted: Fri Nov 26, 2004 3:25 pm     Reply with quote

Yes, I did. I even checked the RS232 on another program with 16f76. It works just fine.

when I used this connect on 12f675, this thing just happen, right now, what ever I click, it will return me a 'X', and the hyperterminal show error message.

Code:

#if defined(__PCM__)
#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock = 4000000)
#use rs232(baud=9600, parity=N, RCV=PIN_A3,XMIT=PIN_A2)

void main ()
{
  char ch;
  setup_comparator(NC_NC_NC_NC);

  while(1)
     {
        output_high(PIN_A0);
        delay_ms(200);
        output_low(PIN_A0);
        delay_ms(200);
        ch=getchar();
        putc(ch);
       if(ch=='a');
       {
        output_high(PIN_A1);
        delay_ms(200);
        output_low(PIN_A1);
        delay_ms(200);
        }

      }
}
 
Guest








PostPosted: Fri Nov 26, 2004 3:46 pm     Reply with quote

right now I used the following program, it isetting the right char after print out, but the led connected to PIN_A2 is on whenever I click a letter, no matter. where is the problem

Code:

#if defined(__PCM__)
#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock =4000000)
#use rs232(baud=9600, parity=N, RCV=PIN_A3,XMIT=PIN_A2)

void main ()
{
  char ch;
  setup_comparator(NC_NC_NC_NC);
  SETUP_ADC_PORTS(NO_ANALOGS);

  while(1)
     {
        output_high(PIN_A0);
        delay_ms(200);
        output_low(PIN_A0);
        delay_ms(200);
        ch=getchar();
        putc(ch);
       if(ch=='a');
       {
        output_high(PIN_A1);
        delay_ms(200);
        output_low(PIN_A1);
        delay_ms(200);
        }

      }
}


Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 4:57 pm     Reply with quote

Quote:

right now I used the following program, it isetting the right char after print out,

Does it start running magically?

Young, you are fighting hard with the 12F675 trying to receive a char from a PC
through RS232 since June/04 and getting odd results frequently.
Could you pls tell us a brief description of the hardware tools you are using
to test your codes?
I guess you are working with a protoboard. Am I rigth ?

Humberto
Guest








PostPosted: Mon Nov 29, 2004 7:40 am     Reply with quote

thank you , it is working right now, It was not the problem of RS232 communication , it was the setup of the port which cause me problem.
padamo



Joined: 07 Dec 2004
Posts: 1

View user's profile Send private message

Missing line in Example 8 in 12F675 Kit
PostPosted: Fri Dec 17, 2004 7:50 am     Reply with quote

It is easy to make the mistake to not set up the port pins into the digital mode because the code in the 12F675 kit example 8 is missing a line. The example does not do:

setup_adc_ports(NO_ANALOGS);

which causes getc() to return without waiting for a character.
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