Author Topic: INTOSC madness  (Read 2482 times)

0 Members and 1 Guest are viewing this topic.

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 581
  • Country: gb
INTOSC madness
« on: March 11, 2021, 07:10:28 pm »
I'm using a 12F683 and have been setting FOSC = INTOSCIO and everything is fine.

Then I changed things (extra info included, the only other thing I changed was the freq from 4MHz to 1MHz):
Code: [Select]
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 1000000

#pragma config FOSC = INTOSC

This is so I can output the clock.

Now I get this error:
683_Shift_Reg.c:14:: error: (1363) unknown configuration setting/register (FOSC = INTOSC) used

Could I please have a clue as to where to look for the right command, cheers.
You can release yourself but the only way to go is down!
RJD
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5370
  • Country: nl
Re: INTOSC madness
« Reply #1 on: March 11, 2021, 07:57:17 pm »
Set _XTAL_FREQ back to 4MHz?


Or:
Use your IDE to seach through the "library" code & header files for "_XTAL_FREQ" and how it is used.
It's likely that dependent on different ranges of values different settings are chosen, and the settings for 1MHz apparently do not agree with FOSC = INTOSC.

You can of course also search for those macro names.
 

Offline cv007

  • Super Contributor
  • ***
  • Posts: 1061
Re: INTOSC madness
« Reply #2 on: March 11, 2021, 08:28:46 pm »
Look in pic/dat/cfgdata/12f683.cfgdata-

INTOSCCLK is probably what you are looking for (or a couple other name variations).
 

Offline hexreader

  • Frequent Contributor
  • **
  • Posts: 302
  • Country: england
Re: INTOSC madness
« Reply #3 on: March 11, 2021, 09:00:33 pm »
cv007 is of course correct with INTOSCCLK

The way I would have found this is:

From the MPLABX IDE Select:

 - Production
 -       Set Configuration Bits
 -            to the right of field FOSC select the down arrow
 -                choose from the drop-down list

Either "Generate Source Code To Output" and copy/paste the resulting output to your code window, or manually edit as you prefer
« Last Edit: March 11, 2021, 09:03:08 pm by hexreader »
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 4810
  • Country: us
Re: INTOSC madness
« Reply #4 on: March 11, 2021, 09:54:17 pm »
Probably I misunderstand.  Do you want intosc out using the internal oscillator or a crystal?

The setting for 1MHz is b'0100xxxx' in the OSCCON register if using the internal oscillator.  If using a crystal, it doesn't matter.  Then in configuration, you need to define INTOSCIO or INTOSC and so forth.
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 581
  • Country: gb
Re: INTOSC madness
« Reply #5 on: March 13, 2021, 06:20:07 pm »
Thank you all very much.

I wanted to output the internal oscillator. It wasn't the freq that was the problem, thanks, see below.

Thank you, the command: INTOSCCLK worked perfectly.

I had completely forgotten about the "Set Config Bits" pull-downs. I generally copy all that stuff from previous projects and alter the things I need to, hence my INTOSC error. I will  use that in future, thank you.

Interestingly, I looked in the file, 12f683.cfgdata and found:
CVALUE:5:INTOSCCLK,_INTOSC,_INTRC_OSC_CLKOUT:INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN

Of course, INTOSCCLK worked but, for fun, I tried: _INTOSC.
This output the clock at the expected freq but instead of being a nice, sharp square wave, it's edges were curved like you get when there is lots of capacitance around.
When I went back to INTOSCCLK it was the nice, sharp wave again.

Not a problem, just interesting.

You can release yourself but the only way to go is down!
RJD
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->