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 CCS Technical Support

Trouble Setting a Pin as an Input

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



Joined: 21 Dec 2005
Posts: 25

View user's profile Send private message

Trouble Setting a Pin as an Input
PostPosted: Wed Feb 20, 2013 10:31 am     Reply with quote

I have a project I have started with the PIC10f320 micro controller. I want to just get a simple program running setting Pin1 and GP0 as an input (eventually I want to set it as an Analog input). The problem I am having is that the PIC appears to be driving the pin low, even though I have assigned it to an input. The input right now is being fed by a power supply through a 10k ohm resistor and a 1uf filter cap (tied between signal and Gnd). I checked and the maximum recommended input impedance to be 10kohm. When I apply the analog voltage directly to the PIC instead of through the resistor/cap I get the correct voltage and even the analog reads work correctly but it does pull significant current. This is why I believe I am just not setting the pin up correctly as an input but I have tried setting the PORTA, LATA, TRISA, ports all to the settings I believe they should be. Any help would be great.

The program I have tried to run is:

I am running Win 7:
CCS Studio: PCWHD 4.134

Code:

#case
#include <10f320.h>
#device ADC=8
#fuses NOWDT, INTRC
#use delay (internal=8000000)
#use standard_io(A)

#byte PORTA = 0x05
#byte LATA = 0x07
#byte ANSELA = 0x08
#byte TRISA = 0x06
#byte WPUA = 0x09
#byte ADCON = 0x1f
#byte ADRES = 0x1E


void main()
{
   int8 velocity[10];
   int16 avgVelocity = 0;
   int ndx = 0;
   int8 overRateDetect = 0;
 
   delay_ms(2000);

   PORTA = 0x01;
   LATA = 0x00;
   ANSELA = 0x01;
   TRISA = 0x01;
   WPUA = 0x00;
   ADCON = 0b10000001;

   while (1)
   {
     

   }
}
ralpok



Joined: 21 Dec 2005
Posts: 25

View user's profile Send private message

PostPosted: Wed Feb 20, 2013 10:45 am     Reply with quote

I solved this problem myself but figured I would post the solution in case it helps anybody else. On this PIC the GP0 pin is shared as the ICSP data pin. I was using the CCSLoad to load and run the program but left the programmer plugged in while I was doing the "running". It appears that this was the issue and the programmer was pulling this PIN low during this operation.

Hope this helps
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