FC7 PIC10F322 – Oscillator Error

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

FC7 PIC10F322 – Oscillator Error

Post by viki2000 »

Hi,

I have just seen your recent Vlog 7 about uC32 PWM on FC8:
http://www.matrixtsl.com/blog/flowcode- ... -with-pwm/
and being inspired by it I wanted to try a simple test with that code with PIC10F322 and PWM in FC7.
The PIC10F322 Datasheet Oscillator Module - page 24:
http://ww1.microchip.com/downloads/en/D ... 01585D.pdf
says that it is possible 16MHz clock with internal oscillator and of course I have test that in the past and it works up to 16MHz.
The FC7 does not let me 16MHz. It says 8MHz is max. allowed.
Can you help to correct that error?
Flowcode7_PIC10F322_OSC_Error.jpg
Flowcode7_PIC10F322_OSC_Error.jpg (49.08 KiB) Viewed 8099 times
Attachments
PIC10F322_test PWM.fcfx
(8.2 KiB) Downloaded 226 times

hackinblack
Posts: 26
Joined: Mon Apr 17, 2017 9:55 pm
Has thanked: 2 times
Been thanked: 14 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by hackinblack »

The Osc speed selection dropdown does stop at a maximum of 8Mhz,which is wrong for this chip.
it's capable of 20Mhz clocked PWM. But your settings for the osc type are wrong..
you have ' EC on CLKIN pin ' selected...not the internal HS osc.
I changed some of the settings and added a C-block for the clock selection,from an XC-8 example)
here
http://e101.webs.com/pic10f322-sample-io-code
but it is still fixed at 8Mhz :(
Attachments
PIC10F322_test_mod_PWM.fcfx
(8.41 KiB) Downloaded 246 times
osc selection bit error.PNG
(18.96 KiB) Downloaded 2833 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by LeighM »

Thanks.
Please try this updated file, drop into your Flowcode7 installation \FCD\PIC directory
Attachments
10F322.fcdx
(11.72 KiB) Downloaded 219 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by medelec35 »

Hi Viki,
Whilst waiting for Matrix to change the maximum speed,
If it's urgent you can modify maximum speed within fcdx file.

For 64 bit windows 10F322.fcdx can be found in:

Code: Select all

C:\Program Files (x86)\Flowcode 7\FCD\PIC\
32 bit windows

Code: Select all

C:\Program Files\Flowcode 7\FCD\PIC\
At the top of 10F322.fcdx you will see:

Code: Select all

<root>
<device name='10F322' product='PIC' family='10F' bits='8' >
    <clock max_speed='8000000' master_divider='4' default='8000000' />
Just change the speed, overwrite the original 10F322.fcdx then you can use the Reload option:
16MHz.png
(36.13 KiB) Downloaded 2828 times
Martin

Edit:
Although Leigh has posted the fix,
I will leave this in case anyone has a similar with other target devices.
Martin

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by viki2000 »

Thank you LeighM and medelec35 for the solution. It works now indeed with 16MHz.
As hackinblack is right with the 20MHz observation when it comes to External Clock (EC) – datasheet page 168, TABLE 24-6, would that imply that we have to change the “10F322.fcdx” to 20MHz?

Code: Select all

<root>
<device name='10F322' product='PIC' family='10F' bits='8' >
    <clock max_speed='20000000' master_divider='4' default='8000000' />
@hackinblack
Your observation is definitely right. I noticed mistake by myself that after I asked the question, but it did not matter too much at that point. Later I changed too the Oscillator Selection bit to Internal oscillator.
One good additional question here would be if we really need that C code in the beginning, where we initialize the oscillator?

Code: Select all

#define _XTAL_FREQ 16000000
#pragma config FOSC = INTOSC

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by viki2000 »

Are my last 2 questions above improper or not interesting somehow?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by LeighM »

It’s difficult to be an expert on every PIC chip, and people only tend to answer if they are fairly sure of the answer.
The datasheet seems to indicate that the maximum clock is 16MHz, despite the PWM table including 20MHz.
You are free to edit the FCD file for this device to extend the max frequency to 20MHz, but whether the clock in can be driven at that rate I don’t know.

edit: Ben has just pointed me in the direction of page 158, I didn't get that far earlier :lol:
Last edited by LeighM on Fri Jun 15, 2018 3:23 pm, edited 1 time in total.

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: FC7 PIC10F322 – Oscillator Error

Post by Benj »

Hello,

No FCD file editing should be required.

If VDD <= 2.5V max clock = 16MHz
If VDD > 2.5V max clock = 20MHz

The clock speed in the project options can be selected from the drop down list or the value can be typed in directly. e.g. for values not in the list.
2018-06-15 14_42_31-Project Options.png
(10.67 KiB) Downloaded 2783 times
Just been chatting to Leigh and here are the 10F FCDs complete with the correct max clock settings.
PIC.zip
(15.44 KiB) Downloaded 217 times

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: FC7 PIC10F322 – Oscillator Error

Post by viki2000 »

Thank you for the corrected files.

Post Reply