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

Why wont pin toggle???

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



Joined: 21 Aug 2009
Posts: 15
Location: Texas

View user's profile Send private message

Why wont pin toggle???
PostPosted: Fri Jun 04, 2010 10:18 am     Reply with quote

I am trying to make PIN_A4 of a PIC18F252 toggle from low to high but it will not work. I try the same code on PIN_A3 and it works perfectly. What am I doing wrong???

Code:

#include <18f252.h>

#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

void main()
{
   setup_port_a(NO_ANALOGS); //no analog inputs
   set_tris_a(0x00); //all outputs
   while(TRUE)
   {
      output_low(PIN_A4);
      output_low(PIN_A3);
      delay_ms(1000);

      output_high(PIN_A4);
      output_high(PIN_A3);
      delay_ms(1000);
   }
}

mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

Reply
PostPosted: Fri Jun 04, 2010 11:14 am     Reply with quote

On page 10 of the PIC18F252 datasheet it says regarding RA4:

Digital I/O. Open drain when configured as output.

You will need external pullup for it to work. Also you don't need this line:
Code:

set_tris_a(0x00); //all outputs

The compiler set the direction of the pins for you when you use the output_high function.
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