Problems with analog inputs by migration from a PIC 12F617 to a PIC 12CE674

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

Moderator: Benj

Post Reply
Wieger
Posts: 2
Joined: Mon Feb 20, 2023 12:34 pm
Been thanked: 1 time
Contact:

Problems with analog inputs by migration from a PIC 12F617 to a PIC 12CE674

Post by Wieger »

Hello there everybody,

My first question of this forum.

I have hundreds of PIC chips 12CE674 from a project of 20 years ago, this are OTP types. (One Time Programmable) . I want use this devices.
I decide first to make an application with a almost similar type 12F617.
I use Flowcode 8 with the EB006V.7 board.

I make an application for illumination a staircase with 16 steps, each step have his own RGB strip. The 3 LED’s are driven by an PWM interrupt routine. I used the 2 analog inputs to manage the LED strips.
AN0 for the desired color and intensity and AN1 for the select the desired step.
Normally you would use an UART for this kind of application but the 674 has no hardware device UART.
I can use a software UART of the FC components, but it don’t work well at the internal clock speed of 4 MHz. in conjunction with the PWM interrupt routine.

I can simulate the application and also programming the device with help from de EB006 programmer. It works well.

Then the next step is to change the target from 12F617 to 12CE674.
I copy de fcfx file and choose in flowcode under target 12CE674.
Then I checked the configuration and it seems ok.

I can’t program the device because it’s not available in de drop down menu from mLoader (4.0.1.2). So I program the device with an external programmer (Minipro).
I checked the configuration word at 2007 and program the device, but it work not properly.

At the beginning of the program I perform a LED test, this ok.
After that I read the voltage from the AN0 and AN1 channels, but the LED’s don’t react?

I know there also differences between the registers.
I see onlyin the 617 a ANSEL and ADCON1 register and in 674 a ADCON0 and ADCON1 register.
Also have the 617 a 10 bit conversion and the 674 a 8 bit.
But I think FC must solved the differences.

When I have a look in the corresponding C-file I see under main as first ADCON1 = 0x07.
So that means that all the inputs are configured as digital input.
I add a C- box in flowcode and write ADCON1 = 0x04, thus only GP0 en GP1 as analog input.

But it’s still not working, maybe something is wrong in the C library of the 674?

Of do I make an another mistake.
I hope somebody can give me some hints.

Best Regards,
Wieger

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Problems with analog inputs by migration from a PIC 12F617 to a PIC 12CE674

Post by Steve »

There is no support for this device in mLoader, so as you discovered you will need to use an alternative programmer.

Also, v8 is quite old now and we can offer limited support for it. Especially for old devices like the 12CE674. But I have some suggestions that may help.

I think there could be some problem with this device in the ADC library files for Flowcode. So it might be better if you configure and read the ADCs directly by accessing the chip registers using C code.

Setting ADCON1=0x04; is a start. You will also need to ensure the TRIS register has GP0 and GP1 set as inputs using TRIS=0x03;. But I suggest you also use ADCON0=0x05; to start the ADC conversion for GP0 (use 0x0D for GP1). Then either wait a set amount, or poll the Go/DONE bit of ADCON0 to determine when the ADC conversion is complete.

Then to read the result, use something like FVC_MYVAR = ADRES; (assuming you have a BYTE variable "MyVar" in your Flowcode program).

Hopefully this will help.

Wieger
Posts: 2
Joined: Mon Feb 20, 2023 12:34 pm
Been thanked: 1 time
Contact:

Re: Problems with analog inputs by migration from a PIC 12F617 to a PIC 12CE674

Post by Wieger »

Hello Steve,

Thanks for your fast reply.
With your advices it's working now.

Before the main loop I added C-code:

ADCON1 = 0x04; /* AN0 and AN1 enabled */
TRIS = 0x03; /* GP0/GP1 input GP2,4,5 output */

Instead of the call of the component macro getByte I added the next instructions:
ADCON0 = 0xC5; /* select AN0 and FRC clock */

Then a delay of 10 us so the conversion must be done.

And then : FCV_STAIR = ADRES; /* read AD result */

And of course the same procedure for AN1 with ADCON0 = 0xCD; /* select AN1 and FRC clock */

Again thank you very much.
Best regards,
Wieger

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Problems with analog inputs by migration from a PIC 12F617 to a PIC 12CE674

Post by Steve »

Great news - thanks for letting us know. I will pass on this information so it can be incorporated into future Flowcode versions.

Post Reply