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:
The code used is below, the define _XTAL_FREQ line was changed for each set of runs:
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.
XTAL 4000000 | 1ms | 1.1KHz |
0.1ms | 9.69KHz | |
0.01ms | 64.2KHz | |
0.001ms | 158KHz | |
XTAL 8000000 | 0.001ms | 136.8KHz |
XTAL 1000000 | 0.01ms | 187KHz |
XTAL 500000 | 0.1ms | 58KHz |
0.01ms | 158KHz | |
0.001ms | 187KHz |
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.