PDA

View Full Version : PIC12F675 at 20MHz ?? (Pic Basic Pro Compiler)



zorgloub
- 20th May 2023, 19:37
Good evening to the community.

PIC12F675 is not planned to operate with an external quartz.
It does not have pin dedicated to an external quartz.
The Datasheet specifies, however, that this little peak can work at 20mHz!?

So, is it enough to use the DEFINE OSC 20 command to operate at 20mHz ??

Indeed, the Picbasic Pro Compiler manual specifies this (§2,3,1): [Note that" DEFINE OSC "does not fix or does not change the real clock frequency! He only indicates to PBP what he should expect.
The actual frequency is defined by choosing a crystal, by changing the configuration of the device, by defining registers in your program, or (most often) a combination of all this.]

But the PIC 12F675 has no pins specifically provided for such an external quartz!?

So how actually run a PIC12F675 in 20mHz and which programming lines should be put in a BasicPro Compiler program?

Thanks for your help.

mpgmike
- 20th May 2023, 19:57
Just looked at the Data Sheet, and best I can tell, it only offers one speed; 4 MHz.

Ioannis
- 20th May 2023, 21:14
The internal oscillator is set at 4MHz. But if you want 20MHz, then you need to sacrifice two pins, GPIO4 and GPIO5 to be used as Crystal connections for the High Speed oscillator.

Or you can drive the GPIO5 pin with an external can oscillator. See page 53 of the datasheet.

The settings for all above is in the CONFIG word during programming of the chip (page 52 of the datasheet).

Ioannis

zorgloub
- 21st May 2023, 20:26
Hi ioannis.
Ok, well seen.
The internal oscillator being 4MHz and if we want to work with a definition at 20mHz, an external quartz is then necessary.
This one connecting to GPIO4 and GPIO5 ... which are indeed well provided for this use!
Which had actually escaped me. :((
I will review my program by considering this precious information.
Thank you again and have a good week everyone!

zorgloub
- 22nd May 2023, 08:13
So, I then have a few questions left about this command define OSC:

1_The "DEFINE OSC 20" command would only make sense if you really use a 20mHz quartz?

2_With a 20mHz quartz, is the simple fact of configuring the fuse "OSC HS" sufficient? Or will we also have to add the DEFINE OSC 20 command in the program?

3_ The fact that the manual specifies that the DEFINE command can be used to change the predefined value of the oscillator makes you think that it is not necessary to use a quartz to actually work at 20mHz ...

4_ Without Quartz What would the impact of the DEFINE OSC 20 order? The timing unit for Pulsin, Pulsout and Pause commands would still be modified?


Thanks

tumbleweed
- 22nd May 2023, 11:11
The ONLY thing the DEFINE OSC command does is inform the compiler what clock speed you're running at so it can adjust various internal timings.

It's completely up to you to set the CONFIG and any runtime settings (OSCCON, etc) that may be required to get you that speed.

richard
- 22nd May 2023, 11:47
there is a manual that answers just about every question available here (https://melabs.com/downloads/PBP_Manual_0609_260.pdf)


eg

4_ Without Quartz What would the impact of the DEFINE OSC 20 order? The timing unit for Pulsin, Pulsout and Pause commands would still be modified?


9420

zorgloub
- 22nd May 2023, 12:28
OK.
If I note that: “Since Defining an OSC value has no effect on PULSIN. The resolution always changes with the actual oscillator speed.”

What then is the true usefulness of this DEFINE OSC command?

Simply or imperatively specify in the PBP compiler the actual operating speed depending on a quartz or simply the internal oscillator.

The only configuration of the OSC fuse bits would not be enough?

I would then deduce that this command must always be placed in the program to specify the actual operating speed at PBP. Correct ?

richard
- 22nd May 2023, 12:50
What then is the true usefulness of this DEFINE OSC command?

its not a command, its a compiler directive

as pointed out it is used to:-
inform the compiler what clock speed you're running at so it can adjust various internal timings. that's it nothing else

do read the manual there is a chapter on define OSC
pause command for instance

DEFINE OSC must be used in order for PBP to accurately calculate and generate code for PAUSE. If no DEFINE OSC is placed in the program, PBP will assume that the system clock will operate at 4MHz and calibrate the generated code accordingly.

zorgloub
- 22nd May 2023, 12:58
OK .
Well understood that it is not an command but a directive for the compiler.
I will assimilate all of this !
Thank you very much for these precious essential information.

mpgmike
- 22nd May 2023, 17:36
Just a thought, since you're using an 8-pin PIC, look at the PIC16F18313. It offers a bunch of features and is probably cheaper than what you're using (unless you have a couple hundred on the shelf already). It can clock up to 32 MHz internally.

Ioannis
- 22nd May 2023, 18:45
zorgloub needs a lot of reading and experimenting to manage a more complicated chip. Lacks understanding of basics...

Me too, have to say :)

Ioannis

zorgloub
- 22nd May 2023, 22:59
Indeed, in all modesty, it must be recognized.
I am rather a little Picaxe user after starting to "play" with Basic Stamp.
I now try to convert my "simple" Picaxe programs with PBP to place it in a slightly cheaper peak.
Thank you, in any case, for the help provided here on this forum with sereinity, patience and competence!
Good night all.