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

strange problem with input pin in 18F1330

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



Joined: 10 May 2004
Posts: 17
Location: barcelona

View user's profile Send private message

strange problem with input pin in 18F1330
PostPosted: Thu Jul 03, 2008 10:15 am     Reply with quote

hello,
this is very strange...
maybe you can help me with this pic, compiler is 4.065

this is my simple program...
Code:
#include <18f1330.h>

#fuses HS, NOWDT,NOPROTECT,NOMCLR

#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A2, rcv=PIN_A3, parity=N, bits=8) 

void main(void)
{

   set_tris_a(0xFF);
   setup_adc(ADC_OFF);
   
   output_low(PIN_B1);
   output_low(PIN_B5);
   output_low(PIN_B7);
 
   
   while(TRUE)
   {

      if(input(PIN_A1))
         output_high(PIN_B5);
      else
         output_low(PIN_B5);
         
      if(input(PIN_A0))
         output_high(PIN_B1);
      else
         output_low(PIN_B1);
     

   }
}


the input(PIN_A1) command not respond!!!

any sugestions??

thanks,

alex
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 03, 2008 10:45 am     Reply with quote

By default the PIC's I/O pins are defined as analog input ports (see the PIC datasheet). You have turned off the A/D-converter with the call to setup_adc() but there is a second function to be used for defining the I/O-pins as digital pins:
Code:
setup_adc_ports( NO_ANALOGS );


Code:
set_tris_a(0xFF);
By default the CCS compiler will automatically configure the TRIS register on each I/O operation so your setting of the TRIS register has little effect and can be removed. If you want to save a little on program memory usage than you can manually set the TRIS register once like you do but than instruct the compiler to not set the TRIS registers by adding the directive #USE FAST_IO at the start of your program.
nicenoise



Joined: 10 May 2004
Posts: 17
Location: barcelona

View user's profile Send private message

PostPosted: Thu Jul 03, 2008 10:49 am     Reply with quote

thanks,
it works!!
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