|
|
View previous topic :: View next topic |
Author |
Message |
aldina
Joined: 09 Oct 2009 Posts: 26
|
PIC16f526 PIN C5 output |
Posted: Wed Sep 15, 2021 2:12 am |
|
|
Hello all,
I can't use PIN C5 of PIC16f526 as output. I've fixed this pin as output port but when I use OUTPUT_HIGH(PIN_C5) nothing happen.
Code: |
##include <16F526.h>
#device ADC=8
#fuses INTRC,WDT,MCLR,PROTECT
#use delay(clock=8000000)
#use fixed_io (c_outputs = pin_c5)
#use fixed_io (b_outputs = pin_b5)
void main()
{
int8 RH_Signal, LH_Signal;
setup_comparator(NC_NC_NC_NC);
setup_adc_ports(PIN_B0);
setup_adc_ports(PIN_B1);
setup_adc(ADC_CLOCK_DIV_16);
output_low(PIN_B5); //sector Lateral Direito
output_low(PIN_C5); //sector Lateral Esquerdo
while (true)
{
restart_wdt();
RH_Signal = 0;
LH_Signal = 0;
RH_Signal = Right();
LH_Signal = Left();
if(RH_Signal >= 50 && LH_Signal >= 50)
{
if(input(PIN_B2) == 1 || input(PIN_C0) == 1)
{
OUTPUT_HIGH(PIN_B5); // ON - Right Light output
OUTPUT_HIGH(PIN_C5); // ON - Left Light output
T_OFF4();
}
else if(input(PIN_B2) == 0 && input(PIN_C0) == 0)
{
OUTPUT_HIGH(PIN_B5); // ON - Right Light output
OUTPUT_HIGH(PIN_C5); // ON - Left Light output
T_OFF4();
}
}
}
}
|
Can someone help me? Why Pin C5 doesn't come HIGH state?
Thanks, |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Wed Sep 15, 2021 2:32 am |
|
|
Key here is the data sheet.
If you look at C5, and table 6-3, you will see that the priority on this pin has
the timer0 input taking priority over the standard I/O functions. You need to
turn this off. Setting Timer0, to use the internal clock should disable this
input selection.
setup_timer_0(T0_INTERNAL);
If you look at Register 4-2, you will see that the default on power on, is
to set the T0CS bit to '1', which has the Timer0 input selected. |
|
|
|
|
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
|