PIC10F322 Applications – Basic Monostable Circuit

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

A PIC10F322 as a 555 timer replacement – why not. I always pulled my hair out when working with most 555 timer circuits.  Resistors, capacitors figuring out the values you need, etc, can be time consuming – why not just program it to do what you need.  

This is some basic monstable circuit code – when a low pulse comes in on PORTA.2 – PORTA.0 will go high for a determined amount of time.  You can adjust the time PORTA.0 is on by changing the value of PulseOut_Time.  This value is in Milliseconds.  Thus 1000 = 1 second. 

 

/*
 * File:   monostable.c
 * Author: Jamie
 *
 * Created on August 14, 2020, 8:52 AM
 */


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

#define PulseOut_Time 1000

void main(void) {
   
    /*Setup*/
    pinMode(0,OUTPUT); //Set PORTA.0 as OUTPUT
    pinMode(2,INPUT);  //Set PORTA.2 as INPUT
    enableWPUA(2);    //Enable WeakPullUp on PORTA.2
    
    while(1)
    {
        if (!digitalRead(2))  //If Input goes low
        {
            digitalWrite(0,HIGH);   //Set PORTA.0 HIGH
            __delay_ms(PulseOut_Time); //Wait
            digitalWrite(0,LOW);    //Set PORTA.0 LOW
       
        }
    }
    
    
    return;
}