Bringing up a new chip 18f24k50 Having some problems. Resolved use OSCCON and not OSCFREQ.

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

Moderator: Benj

Post Reply
chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Bringing up a new chip 18f24k50 Having some problems. Resolved use OSCCON and not OSCFREQ.

Post by chad »

I gave up on the other chip, was getting no support from FC.

I went with the 18f24k50 and I have it sort of running but it is really slow. I have tried to set the config but I must be doing something wrong.

Does any one have a screen shot of the config settings, the clock speed under general and if the internal Oscillator helper is needed with this chip.

I am trying to set it to 48mhz using the internal oscillator at some point I want to play with the usb on the chip.

Thanks,

Chad
Last edited by chad on Mon Oct 19, 2020 4:50 pm, edited 1 time in total.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by stefan.erni »

Hi Chad

try this setting, so your PIC is running on 48Mhz and a note: there is a similar PIC 18F25k50 with more ram for the same price.

regards

Stefan
Config.png
Config.png (277.56 KiB) Viewed 5814 times

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by chad »

Hi Stefan,

That's how I set it up.
Thanks for double checking my settings.

On the bigger chip. I realized that as soon as I saw how much memory I had left after my little test program.
I just can't seem to win.

Anyway, thanks..

Chad
Last edited by chad on Mon Oct 19, 2020 4:52 pm, edited 1 time in total.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by QMESAR »

Hi Guys,

I do not have such an device however
In my opinion it should work as follow
You need to set the frequency of the Internal OSC use the OSC helper the setting of the PLL 3 or 4 times depend on the setting of the OSCCon register if 16MHz is used the you can only set the PLL to 3 which expects and input Frq of 48Mhz then
If you do not set the OSCCON register the internal OSC is running at it default which I expect is 4Mhz

P1.jpg
P1.jpg (57.21 KiB) Viewed 5799 times

P2.jpg
P2.jpg (132.64 KiB) Viewed 5799 times

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by chad »

There is no OscHelper setting that matches. I have to disable the C-code to get it to compile.
Like I said it sort-of runs. It takes 5 seconds to update my little oled display. It then hangs a after a little bit.

I am totally willing to accept that I have something set wrong. I did infact. This one was my fault.

Chad

*edited , my fault.
Last edited by chad on Mon Oct 19, 2020 4:21 pm, edited 1 time in total.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by QMESAR »

Hi Chad

The OSChelper gives all the possible Frequencies for the internal OSC
if you select 16Mhz then
the Internal OSC is running at 16Mhz which is the input frequency to the MUX unit then by setting the PLL bit to 3 times is 3 x16 = 48Mhz Clock frequency as you will see in the above post OSC block diagram
I hope this is more clear

P1.jpg
P1.jpg (22.09 KiB) Viewed 5781 times

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by chad »

This is what I get if I set 16mhz:


18f test 1.c: main()
4195: OSCFRQ = 0x08;
^ (192) undefined identifier "OSCFRQ"
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1

Autoclose turned off


FINISHED

?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by QMESAR »

With me these settings compile just fine
?
can you upload your FC files and I will try to compile it !

P1.jpg
P1.jpg (37.48 KiB) Viewed 5777 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: Bringing up a new chip 18f24k50 Having some problems.

Post by medelec35 »

chad wrote:
Mon Oct 19, 2020 2:49 pm
(192) undefined identifier "OSCFRQ"
The error is because OSCFRQ within C code is not used on your current target device to set internal osc speed.
OSCCON is used instead.

For future reference, just use search (magnifying glass icon) and enter intosc, this is what QMESAR was referring to
That will bring the IntOscHelper up, so add it to 2D or 3D panel
IntOscHelper is used via it's properties to show the correct register name and value to give the required speed.
For example if using 16 MHz internal osc then x 3 pll = 48MHz, then set the IntOscHelper for 16MHz.
That will give you:
IntOscHelper1.png
IntOscHelper1.png (64.64 KiB) Viewed 5771 times
Ignore that warning, as you have set target clock within project options to 48000000
You can copy and paste required value within a C code block.
In this case with

Code: Select all

OSCCON = 0x70;
I'm the same as QMESAR, I don't have the same chip as you, so by stating use OSCCON = 0x70; with multiplier x 3 I could be wrong.
But sounds logical to me.
Martin

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by chad »

Ok So that was a big help. OSCCON and not OSCFREQ helped. That did make it faster. The chip runs for a bit then hangs and resets but that is at least progress. I don't know where I got the oscfreq instead. I adapted my test program from another chip that was already wired up with some pin changes.

Thank you for the help. It is a step forward.

Chad

Here is my little test program. It's basically just a test of a handful of components.
Attachments
18f test 1.fcfx
(24.57 KiB) Downloaded 151 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: Bringing up a new chip 18f24k50 Having some problems.

Post by medelec35 »

chad wrote:
Mon Oct 19, 2020 4:18 pm
The chip runs for a bit then hangs and resets
That usually happens when Watchdog Timer Enable bits is set to enable (within Configuration settings) when you don't clear the watchdog timer with

Code: Select all

MX_CLEAR_WATCHDOG;
within a C code block.
My advice would be to set Watchdog Timer Enable bits to Disabled Within Hardware
Martin

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by QMESAR »

Duplicated advise

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by QMESAR »

Ok Martin
I leave this post now ,Sorry I posted just after you posted did not see your response

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems.

Post by chad »

Little update.

I was sending data to a UART. I disabled the enable but didn't disable the sending. That was hanging the chip. I also disabled the WDT, hopefully that will fix the chip resetting.

Thank you guys for helping, It is appreciated.

Chad

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: Bringing up a new chip 18f24k50 Having some problems. Resolved use OSCCON and not OSCFREQ.

Post by medelec35 »

Hi QMESAR,
QMESAR wrote:
Mon Oct 19, 2020 4:33 pm
I leave this post now ,Sorry I posted just after you posted did not see your response
All posts are useful, even if duplicated.
Far better to get a reply from multiple people rather than from no one.
My apologises for jumping in.
I should have waited longer before replying.

Hi chad,
My fingers are crossed for you.
Lets hope target device works well.
I always start any new devices with a one second flasher test.
Although if using a scope or logic analyser I set the delay for 10ms.
Makes no difference on the time delay, so long as its not in microseconds & the on/off time duration match.
Martin

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Bringing up a new chip 18f24k50 Having some problems. Resolved use OSCCON and not OSCFREQ.

Post by QMESAR »

Hi Martin

No issues ,I just did not see you already replied and that was the meaning not to double post the same things ,
I apologize if you feel I did not like that you posted That was really not the intention .

Chad as Martin I really hope you get things going all fingers crossed ,

Post Reply