View previous topic :: View next topic |
Author |
Message |
smoglu
Joined: 23 Jun 2010 Posts: 7
|
possibly a bug [RESOLVED] |
Posted: Tue Jul 20, 2010 4:37 am |
|
|
Hi. The following little code does not work. 2 LEDs are connected to pin A4 and A5, and pin A4 does not light up the LED but pin A5 does. There is a problem with pin A4.
Compiler Version: 4.068
Code: |
#include <16F876A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=20000000)
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
output_high(PIN_A4);
output_high(PIN_A5);
}}
|
Last edited by smoglu on Tue Jul 20, 2010 5:54 am; edited 1 time in total |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Jul 20, 2010 5:37 am |
|
|
On some PICs pin A4 is Open Collector, ie. it will not pull high, it only pulls low. Check the datasheet for your PIC as I am not familiar with the 16F876A. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
smoglu
Joined: 23 Jun 2010 Posts: 7
|
|
Posted: Tue Jul 20, 2010 5:53 am |
|
|
Yes, you are right. PIC datasheet says A4 is open-drain type.
Thanks. |
|
|
|