In XC8 what step to be taken to get fr. 4mhz of the mcu 16f628a after the following code..
//--------
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function) // bit cofiguration for internal osc
#include <xc.h>
#define _XTAL_FREQ 4000000 // 4MHz This is the speed the controller is running at
//what would be the next action to get 4mhz frq.
tnx.
Tnx Jayant,
then what should be the case for 8, 16, and 20 mhz for selection of internal osc.
Then is there only changes for below directive,
#define _XTAL_FREQ x // x = 8/16 or 20 MHz
pl correct me.
The PIC16F628A has only one internal oscillator and it is 4MHz.
If you want higher frequency you should use external crystal the PIC can support upto 20MHz
Jayant
PermalinkHi SA,
I can see that you are using the configuration bits (Windows -> PIC memory Views -> Configuration bits) option in you MPLABX to generate the code and what you have done is also correct.
When you use this line
It already means that you are instructing the PIC to use the internal 4MHz oscilator. You do not have to do anything more than this just continue your program
In case if you are not using the configuration bits and what to set the fuse bits by yourself then refer page 96 on the datasheet. There are totally 8 different options in which you can set the clock by setting the FOSC0, FOSC1 and FOSC2 bits. I am pasting the bit details below
Hope this helps !
- Log in or register to post comments
Joined May 19, 2015 213Tuesday at 03:45 PM