Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Internal Clock and output frequency

chopnhack

New Member
Hello all, I am investigating the use of a PIC12F675 to produce various frequencies on one of its GPIO's. I am aware and have experimentally confirmed that the INTRCCLK will output a ~1MHz signal on pin 3. I wanted to see if I could get a range of frequencies by simply toggling a port on and off. I got some unusual results that I wanted to see if anyone knows why they would occur. It seems as if there is a ceiling of ~187KHz. Results are in the table below:
XTAL 40000001ms1.1KHz
0.1ms9.69KHz
0.01ms64.2KHz
0.001ms158KHz
XTAL 80000000.001ms136.8KHz
XTAL 10000000.01ms187KHz
XTAL 5000000.1ms58KHz
0.01ms158KHz
0.001ms187KHz

The code used is below, the define _XTAL_FREQ line was changed for each set of runs:

C:
// CONFIG
#pragma config FOSC = INTRCCLK  // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-Up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON       // GP3/MCLR pin function select (GP3/MCLR pin function is MCLR)
#pragma config BOREN = OFF      // Brown-out Detect Enable bit (BOD disabled)
#pragma config CP = OFF         // Code Protection bit (Program Memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)

#include <xc.h>

#define _XTAL_FREQ 500000

 void main (void)
 {
  // SET UP
  TRISIO = 0b000010;          //Only AN1 is a input all else are outputs.
    
  while(1){
      GPIO = 0b000000;        //Off 
      //__delay_ms(1);
      GPIO = 0b100000;        //GP5 On 
      __delay_ms(0.001);
  }

The scaling from 1ms to 0.1ms is nearly perfect with 4MHz intrcckl - 1 to almost 10KHz, but it seems to fall off from there. Any thoughts? Thank you all in advance.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top