View previous topic :: View next topic |
Author |
Message |
Marcos Guest
|
Read PIN in PIC 16F628A |
Posted: Sun Sep 24, 2006 9:10 am |
|
|
i Need read input pins in PIC16F628A, I used pin BIT_TEST(*5,1). For example PIN A1. With this formate i didnt se in my firmware the diference when i phisical input 5V ou 0V. i tried the comand input(a,pin_a1) but dont running too.
you can help me? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Sep 24, 2006 9:38 am |
|
|
Quote: |
i Need read input pins in PIC16F628A, I used pin BIT_TEST(*5,1). For example PIN A1.
|
In all the PIC16 series, Port A is the Analog Port connected to the analog to digital converters or analog comparators.
By default, after power up this port is configured as analog, unless you configure this port as digital with the following line:
setup_adc_ports(NO_ANALOG);
Then to read an input:
Code: |
if(input(PIN_A1))
{ ...do this }
else
{ ...do that }
|
Humberto |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 24, 2006 1:47 pm |
|
|
Quote: | setup_adc_ports(NO_ANALOG); |
That function isn't supported for the 16F628A, because it doesn't have an ADC.
Quote: | I need read input pins in PIC16F628A, I used pin BIT_TEST(*5,1).
|
The comparator should be turned off by the start-up code which
is inserted by the compiler. But it's possible that if you have an
older version of the compiler the start-up code may be incorrect.
Post your compiler version. This is a 4-digit number, such as 3.191,
or 3.236, or 3.249, etc. You can find it at the top of the .LST file.
The .LST file will be in your project directory. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Sep 24, 2006 4:16 pm |
|
|
Quote: |
That function isn't supported for the 16F628A, because it doesn't have an ADC.
|
Yap, you are rigth PCM programmer, I mention it: "analog to digital converters or
analog comparators" but made a mistake in the way to turn off such module:
setup_adc_ports(NO_ANALOG);
instead of:
setup_comparator(NC_NC_NC_NC);
Humberto |
|
|
|