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

PIN_A4 DIRECTION PROBLEM!!

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



Joined: 10 Sep 2003
Posts: 13

View user's profile Send private message

PIN_A4 DIRECTION PROBLEM!!
PostPosted: Fri Jan 02, 2004 4:03 am     Reply with quote

I am trying to use PIN_A4 pin as I/O..For testing, I connected a LED serially via 3.3k PULLUP ressistor to PIN_A4.. And I written this simple code snipped..

while(1){
output_low(PIN_A4);

delay_ms(250);

output_high(PIN_A4);
delay_ms(250);
}

It did not blink..But why.. When I use assembly code to achieve the goal, it works well..I compile the code that below with MPLAB.. Such as,

movlw 0x00
mowwf TRISA

cycle

bsc PIN_A4
call delay_enough
bsf PIN_A4
call delay_enough
goto cycle

end

Would someone please explain what the problem is ?

Thank you for your interest..
Jos



Joined: 15 Sep 2003
Posts: 4

View user's profile Send private message MSN Messenger

PostPosted: Fri Jan 02, 2004 4:20 am     Reply with quote

You are probably using a PIC with a built-in A/D converter. Try to include these lines in your initialisation.

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);

Greetz
Ttelmah
Guest







PostPosted: Fri Jan 02, 2004 5:26 am     Reply with quote

Jos wrote:
You are probably using a PIC with a built-in A/D converter. Try to include these lines in your initialisation.

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);

Greetz

Another possibility.
On a lot of chips, A4, will only pull 'down', not 'up'. It has an open collector driver, with no pull up ability.
Check the device data sheet, and the curcuit used, to verify that the pin can pull in the direction needed to operate the LED.

Best Wishes
micro



Joined: 10 Sep 2003
Posts: 13

View user's profile Send private message

Still doesn't work!!
PostPosted: Fri Jan 02, 2004 5:32 am     Reply with quote

Thank you Jos.. I tryed to what you say but negative..But It still doesn't work..
I am using 16f877A...

I pulled up PIN_A4 to +5V with serially 3.3K resistor and a LED...I know that PIN_A4 is an open collector output. But I don't know why it doesn't work like I want..??
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

Check the Comparator Module
PostPosted: Fri Jan 02, 2004 7:46 am     Reply with quote

RA4 can be configured as an output for one of the comparators and will then not work as a standard digital output. Check the config registers and verify that the comparators are off. The CM bits (0, 1, and 2) in the CMCON register (9Ch) should be set. This is their reset default.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Fri Jan 02, 2004 9:44 am     Reply with quote

Well if the asm code works, the only difference is the set trisa. You didn't post the complete CCS program so I don't know if you chose fast_io. Try setting the trisa register and see if that 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