djc
Advanced Member level 1
Hi,
I want to use internal oscillator of PIC10F320. I am using MikrocPro. As suggested in datasheet I configured OSCCON register for 16Mhz internal oscillator operation. Cleared 'FOSC' bit in configuration word in edit project setting. just toggled a port pin in timer interrupt. Checked it on scope and it is showing frequency of 14.674 Hz, though it should be 15Khz. Program is as follows,
Can somebody plz tell me what are the other settings needs to be done to achieve desired frequency.
I want to use internal oscillator of PIC10F320. I am using MikrocPro. As suggested in datasheet I configured OSCCON register for 16Mhz internal oscillator operation. Cleared 'FOSC' bit in configuration word in edit project setting. just toggled a port pin in timer interrupt. Checked it on scope and it is showing frequency of 14.674 Hz, though it should be 15Khz. Program is as follows,
Code:
#define channel_1 PORTA.B0
#define channel_2 PORTA.B1
char x=0;
PortNClock(){
TRISA = 0b00000100; // RA2 as as i/p,RA0 RA1 as o/p
PORTA = 0x00;
ANSELA = 0b00000100; //RA2 as ADC i/p
OSCCON = 0x01111001; // 16 MHz internal clock
CWG1CON0 = 0x00; //complementry waveform generator off
CWG1CON1 = 0x00; //complementry waveform generator off
CWG1CON2 = 0x00; //complementry waveform generator off
}
Timer0(){
INTCON = 0b11100000; //Enable All interrupts and Timer0 interrupt
T0CS_bit = 0; //Internal clock /4
PSA_bit = 1; //Prescalar is inactive
TMR0 = 0x00;
}
void interrupt(){
if(INTCON.TMR0IF){
TMR0IF_bit = 0;
}
channel_2=~channel_2;
TMR0 = 0x00; //EC
}
void main() {
PortNClock();
Timer0();
while(1){
}
}