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

PIC16F1823 I/O configuration problem

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



Joined: 30 Sep 2003
Posts: 120

View user's profile Send private message

PIC16F1823 I/O configuration problem
PostPosted: Wed Apr 11, 2012 9:11 am     Reply with quote

Trying to set up one digital input (on C4) and the first 7 analog inputs, but pin A0 comes up outputting 0 volts and sinking a few mA. Also pin A3 shows 2.5 volts (Vdd/2) even though the weak pull-up is enabled. (The PU on C4 works correctly.)

Version 4.121 compiler

Code:

#include <16f1823.h>
#device ADC=10

#fuses NOMCLR,NOWDT,NOPUT,INTRC_IO,NOBROWNOUT,NOLVP,NOIESO, NODEBUG

#use delay (clock=8000000)
#use standard_io(A)

#byte OPTION_REG = 0x95
#byte WPUC = 0x20E
#byte WPUA = 0x20C
#byte DACCONzero = 0x118
#byte TXSTA = 0x19E

void main()
   {
   setup_oscillator(OSC_8MHZ)   ;   
 
   OPTION_REG = 0b00000000;
   WPUC = 0b00010000;  //pullup on pin C4
   WPUA = 0b00001000;  //pullup on pin A3
   setup_comparator(NC_NC_NC_NC);
 
   set_tris_c(0b00010111);
   set_tris_a(0b11111);
   setup_vref(VREF_ON |VREF_ADC_4v096 ) ;
   setup_adc( ADC_CLOCK_INTERNAL );
   setup_dac(DAC_OFF); 
   DACCONzero = 0;  // disconnect DAC output from pin A0 (DACOE=0)
   TXSTA = 0;      // disable transmit (TXEN=0)
   setup_adc_ports( sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6 |VSS_VDD );

   }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2012 2:13 pm     Reply with quote

Two of those pins are used by the ICD programmer. Pin A0 is for ICSP
data, and pin A3 is the \MCLR pin. Do you have an ICD connected to
the board ?

How are you measuring these voltages ? With an oscilloscope ? Or a
voltmeter ?
johnl



Joined: 30 Sep 2003
Posts: 120

View user's profile Send private message

PostPosted: Wed Apr 11, 2012 2:17 pm     Reply with quote

I disconnected the ICD2 from the PIC before checking.

I am measuring with a scope and the levels are pure DC.
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Wed Apr 11, 2012 2:40 pm     Reply with quote

Have you recompiled in 'non debug' mode?. Though you show this in the code posted, if you are using MPLAB for example, _it_ has to be told to compile into 'release' mode, or it will still select DEBUG mode by default.

Best Wishes
johnl



Joined: 30 Sep 2003
Posts: 120

View user's profile Send private message

PostPosted: Wed Apr 11, 2012 3:36 pm     Reply with quote

The problem was a bad connection on the PCB on the resistor between the analog source and the input pin. Testing on the resistor leads, it looked like the pin was drawing current, but that was a bad probe connection because of oxidized leads. I shouldn't use old parts for prototyping.

The problem of low voltage on A3 was also my fault. I had wired a Vpp clamp circuit up on the board and it was dragging down the pull-up resistor with a lower resistance.

BTW, debug/release mode makes no difference.

Thanks much.
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