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

No response from PIN_A1

 
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

No response from PIN_A1
PostPosted: Thu Dec 08, 2005 2:57 pm     Reply with quote

I have the following simple program:

I want to wait for a input from pin A1 and then print out something, however, my program went to an endless loop, even I put PIN_A1 high (by connecting to 5V) and in the loop, it is print out as 0, why?
Code:

#if defined(__PCM__)
#include <16f76.h>
#fuses HS, NOBROWNOUT,NOWDT,NOPROTECT,NOPUT
#use delay(clock =8000000)
#use RS232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7)

main()
{

setup_adc(ADC_OFF);
set_tris_a(0x0F);
while(1)
{
 printf("waiting signal\r\n");
 while(!input(PIN_A1))
 {printf("Pin_A1 is: %u\r\n",INPUT(PIN_A1));
 delay_ms(100);
 }
 printf("waiting signal1\r\n");

}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 08, 2005 3:22 pm     Reply with quote

It could be that CCS is not setting up Port A for digital i/o.

Post your compiler version. I'll check the .LST file.
Guest








PostPosted: Thu Dec 08, 2005 3:33 pm     Reply with quote

thank you:

It is version 3.202
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 08, 2005 3:43 pm     Reply with quote

There's a bug in the CCS start-up code for your version.
They're setting up Port A for all analog i/o pins.
To fix it, add the line shown in bold below, at the top of main():
Quote:

main()
{
setup_adc_ports(NO_ANALOGS);




}
Guest








PostPosted: Thu Dec 08, 2005 3:53 pm     Reply with quote

THANK YOU. YOU ARE RIGHT!
I THOUGHT setup_adc(ADC_OFF); ALREADY SET THE PORT AS DIGITAL INPUT/OUTPUT.
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