PIC10F322 Applications – Basic Astable Circuit

The code (basic_astable.c) and headers can be found in my GitHub here – https://github.com/JamieStarling/MCU_FUN/tree/master/Microchip/PIC10F322/

Continuing with using a PIC10F322 as a 555 replacement – Here is a basic Astable XC code.

The output pulses are on PORTA.0 and the run down of the code is as follows.

We do some basic setup, Set the speed of the cpu to 16Mhz, set PORTA.0 as output.

The code loop, toggles PORTA.0 on and off.

At 16Mhz and no delays, the output pulse time is around 83Khz or roughly a 12us pulse – shown here. The frequency is around 41Khz.

10F322 basic astable output

If you wish you can change the value – Delay_Value which for above is set to 0 – since value is in instructions. To get the value you need..

At 16Mhz, the instruction cycle is 4Mhz, or 250ns. To add an additional 1us delay you would put in the value of 4.

If you need something that goes higher than 41Khz, we need to take a look at the NCO (Numerically Controlled Oscillator module) – which if I recall – tops out at 500Khz.  I will do that in the next post.

For now – is the basic astable code.

/*
 * File:   basic_astable.c
 * Author: Jamie
 *
 * Created on August 15, 2020, 9:38 AM
 */


#include "includes/10F322_deviceconfig.h"
#include "includes/gpio.h"
#include "includes/osc.h"

#define Delay_Value 0  //Delay in instructions

void main(void) {
    
    pinMode(0,OUTPUT);
    cpuFreqSelect(MHZ16);
    
    while(1)
    {
        digitalToggle(0);
        _delay(Delay_Value);
    }
}