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

Help with a stuck IO Pin

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



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

Help with a stuck IO Pin
PostPosted: Wed Feb 15, 2006 6:41 am     Reply with quote

Hi

I'm using the 16F818 with Compiler version 3.217.

My problem always arises when I try to use pin B3 as an output, it won't change state when programmed. Until now I have got around this by switching to another spare pin which has worked fine. When programmed to go high the pin always stays low and won't alter state at all.

I aways program all pins to a known state at powerup (usually all low) by using the standard output_low (Pin_B0) through to pin B7 command. All other pins will switch to high when programmed to using the standard output_high(Pin_B0) command except for pin B3

I now have an application coming up that needs all pins as outputs so I need to overcome this problem.

Has anyone got any ideas what I'm doing wrong?

thanks in advance

JFK
Humberto



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

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 7:17 am     Reply with quote

Without knowing your code it is difficult to help you, so I just can guess something like
Pin_B3 is usually shared with the ICSP as enable pin.
Does your code has the directive #ICD=TRUE ?


Humberto
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 8:17 am     Reply with quote

No I don't use the ICD here's a simple program that I used earlier today to test it out you will see I switched the redled output to Pin B0 from B3 to get it to work.

Code:

#include <touch.h>
#include <stdlib.h>

//Lithium Ion charger
//Revision 1.0
//written on compiler version 3.217
//tested on compiler version 3.217

#define timer 210
#define vconnect 452
#define vmin 258   //minimum battery voltage 10V 
#define imin 63    //switch over current from hi V to lo V
#define ledred (Pin_B0)
#define ledgreen (Pin_B2)
#define onoff (Pin_B6)


long int vbatt,ibatt,minute;
long tick;

void RedLedFlash()

   output_high ledred;
   delay_ms(200);
   output_low ledred;
   delay_ms(200);
}

void Reset()
{
   Output_low onoff;
   Output_low ledred;
   Output_low ledgreen;
   vbatt=0,ibatt,minute=0,tick=0;
}

#int_RTCC
void RTCC_isr()
{
   tick++;
      if(tick == 15000)
         {
            minute++;
            tick=0;
         }
}

void main()
 {
   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_16);
   goto start;

charged:         
   set_adc_channel(0);                  
   output_low onoff;    //switch charger off
   output_high ledgreen; //change led to show charged
   output_low ledred;
   disable_interrupts(global);

   do
   {
   vbatt = read_adc();
   delay_ms(500);
   }
   while(vbatt > vmin);

start:
   Reset();

   do               //test for battery connected
   {
      set_adc_channel(0);           
      delay_us(100);
      vbatt = read_adc();
     RedLedFlash();
   }
   while (vbatt < vmin);

   output_high onoff;   //switch charger on and indicate charging
   output_high ledred;
   enable_interrupts(global);

 do                  //loop until battery disconnected or charged            
{
   delay_ms(1000);
   vbatt = read_adc();
    if (vbatt >= vconnect) goto charged;
   
   set_adc_channel(2);
   delay_ms(500);
   ibatt = read_adc();
   
    if(ibatt < imin) goto charged;
   if(minute > timer)goto charged;
   set_adc_channel(0);
   
}
 while (1); 
  }
drh



Joined: 12 Jul 2004
Posts: 193
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 8:24 am     Reply with quote

Look at your #FUSES statement.
Change LVP to NOLVP.
_________________
David
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