PIC12F683 not receving inputs on Port A1

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

PIC12F683 not receving inputs on Port A1

Post by Ondra »

Good day all. I am having some trouble using the PIC12F683. It seems that the device will not receive input on Pin A1.
I searched the forum and found that this device has had some issues with its fcd file. Since what I am trying to do is
simple I am inclined to think that the problem might be with the fcd file. I created a simple loop, flashing an LED on for 1
second, Off 1 second. It works fine. I than, using the same file added an input on port A1 to switch the LED on when high
then off when low. And It doen't work. I searched the forum and downloaded what I believe is the latest fcd for the 12F683,
and still it doesn't work. Could someone have a look into this? I tried using the internal clock set at 4 and then at 8MHz,
Watchdog is off. Thanks in advance.

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Hello Ondra

Would you mind posting the C code generated by your program and I will see if I can spot why this is going wrong.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Adding the following to the very start of your program in a c code icon should allow the device to work correctly,

Code: Select all

cmcon0 = 0x07;
ansel = 0x00;
I will still need the C code file and this way I should also be able to fix your problem at the FCD level.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

Here it is.
Attachments
Pebble led test.c
(3.64 KiB) Downloaded 287 times

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

Thanks Benj. That C code worked.

Ondra

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

Hi Benj, I seem to be having the same problem with port pin A3 not receiving
acknowledging the input change.

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Hi Ondra

Ok the C code confirmed that your FCD file was missing a initialisation instruction. I will update this in the next release of Flowcode but for now you can add the following to your FCD file if you do not want the have to add that C code to every program.

In the

Code: Select all

 section of the 12F683.FCD file find the line that starts.

Initialise="

Change this line to look like this.

Initialise="ansel = 0x00;\ncmcon0 = 0x07;\n"

Then save the file and restart Flowcode and you should no longer require the C code. 

Not sure why your A3 input pin is not working though it is multiplexed with the MCLR, have you disabled this in the configuration?

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

Not sure why your A3 input pin is not working though it is multiplexed with the MCLR, have you disabled this in the configuration?
No I did not disable it. Should I have?

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Hello Ondra

Well if you don't disable the MCLR function in the config settings then the pin will act to reset the device if you bring the input signal low.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

GP3 pin 4 is the MCLR pin. It's A3 GP4 Pin 3 that's not working right. Are you saying that disabling the MCLR funtion might clear the issue I am having on A3 GP4 Pin 3? If so I have 2 option internal and external how do you disable the MCLR ?
Also just checking, for the Initialize code is it ncmcon0 or cmcon0.

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Hello Ondra

GP3 is port pin A3 or device pin 4 - This pin is also the MCLR by default
GP4 is port pin A4 or device pin 3 or analogue pin AN3 - This pin is a Oscillator pin by default
GP5 is port pin A5 or device pin 2 - This pin is a Oscillator pin by default

Also the initialise is correct. the \n is converted into a carriage return in the output C code.

Initialise="ansel = 0x00;\ncmcon0 = 0x07;\n"

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

OK, looking at the data sheet, device pin 3 is AN3 default OSC2. So I guess the question should be, how do I change the default oscillator pins to I/O pins, if that's possible.

Ondra

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

Looking at the data sheet I see the following: -
8. INTOSCIO – Internal oscillator with I/O on
OSC1/CLKIN and OSC2/CLKOUT.
By this, I think that it is possible to use the OSC pins as I/O pins. But my clock option under config
does not seem to support INTOSCIO, is their a work around?

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Hello Ondra

If you use the "Internal RC No Clock" option then this is the same as the INTOSCIO setting from the datasheet.

To read pin 3 you would need to use an input icon in single bit mode and read bit A4.

Hopefully this should work to allow you to use this input pin.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Ondra »

That did it. Thanks again. I loooooovvvvvveeee flowcode and the great support. It's the best.

Ondra

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC12F683 not receving inputs on Port A1

Post by Benj »

Brilliant, thanks for letting me know. :mrgreen:

Post Reply