View previous topic :: View next topic |
Author |
Message |
i2c2k
Joined: 23 May 2005 Posts: 3
|
12F675 -> PIN_A3 doesn't work |
Posted: Sat Jul 09, 2005 4:03 am |
|
|
hi,
i wrote a little programme to drive 3 leds and a MOSFET driver.
unfortunately the blue led doesn't work because i get only floating level at the GPIO3 output.
here's the code:
Code: |
#include<12F675.h>
#fuses INTRC, NOWDT, NOCPD, NOPROTECT, NOMCLR, NOPUT, INTRC_IO, NOBROWNOUT
#use delay (clock=4000000)
#use fast_io(A)
#define LED_RED PIN_A5
#define LED_WHITE PIN_A4
#define LED_BLUE PIN_A3
#define PWM_OUTPUT PIN_A0
#define BUTTON_INPUT PIN_A2
void main()
{
port_a_pullups(false);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_OFF);
setup_adc_ports (NO_ANALOGS);
set_tris_a(0b00000100);
output_a(0xff);
while (1)
{
}
}
|
thanks! |
|
|
Ttelmah Guest
|
|
Posted: Sat Jul 09, 2005 4:29 am |
|
|
It never will.
I'm afraid to say 'RTFM'....
On the 12F675, if you read the data sheet, you will find that pin GP3, is _only_ useable as an input. This is because the pin is multiplexed with the programming voltage input, which has to be able to pull the pin well above the +ve supply rail. As such there cannot be a pull-up FET present on the pin, and so the pins where this is done, are always made either 'input only', or 'open collector outputs'. On the 675, it is made input only.
Modify your hardware and your code. Move the LED to pin A2, and put the input push button on A3.
Best Wishes |
|
|
i2c2k
Joined: 23 May 2005 Posts: 3
|
|
Posted: Sat Jul 09, 2005 4:31 am |
|
|
ok, thanks! |
|
|
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Mon Apr 14, 2008 11:10 pm |
|
|
Is PIN_A2 used for something like this too? In my PIC it does not want to go HIGH. |
|
|
Matro Guest
|
|
Posted: Tue Apr 15, 2008 1:30 am |
|
|
40inD wrote: | Is PIN_A2 used for something like this too? In my PIC it does not want to go HIGH. |
Nothing similar for this pin but you have to activate the weak pull-up.
Look for "WPU" register int he datasheet.
Matro. |
|
|
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Tue Apr 15, 2008 2:04 am |
|
|
In datasheet:
Quote: | The weak pull-up device is automatically disabled if the pin is in Output mode |
|
|
|
Matro Guest
|
|
Posted: Tue Apr 15, 2008 2:19 am |
|
|
40inD wrote: | In datasheet:
Quote: | The weak pull-up device is automatically disabled if the pin is in Output mode |
|
If your pin is an output you should be able to have a high level. The pin isn't an open drain one.
Check that COUT is disabled.
You can post a short excerpt of your code.
Matro. |
|
|
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Tue Apr 15, 2008 2:28 am |
|
|
Quote: | Check that COUT is disabled.
|
How to check this? |
|
|
Matro Guest
|
|
Posted: Tue Apr 15, 2008 2:52 am |
|
|
These 2 lines shall be present in your code
Code: |
setup_comparator(NC_NC);
setup_vref(FALSE);
|
You can also read CM2:CM0 value during code execution and check that it is 0b111 (for example with a "if" statement that toggles a LED).
Notice that the comparator is active by default. That's why you have to disable it.
Matro. |
|
|
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Tue Apr 15, 2008 3:02 am |
|
|
Hmm. Not helps!
I just moved output to other pin... |
|
|
|