View previous topic :: View next topic |
Author |
Message |
micro
Joined: 10 Sep 2003 Posts: 13
|
PIN_A4 DIRECTION PROBLEM!! |
Posted: Fri Jan 02, 2004 4:03 am |
|
|
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
|
|
Posted: Fri Jan 02, 2004 4:20 am |
|
|
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
|
|
Posted: Fri Jan 02, 2004 5:26 am |
|
|
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
|
Still doesn't work!! |
Posted: Fri Jan 02, 2004 5:32 am |
|
|
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
|
Check the Comparator Module |
Posted: Fri Jan 02, 2004 7:46 am |
|
|
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
|
|
Posted: Fri Jan 02, 2004 9:44 am |
|
|
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. |
|
|
|