Select Page

Posts From The Art of Technology

 

PIC10F322 XC8 Interrupt Based Delay Timer

In the previous post I wrote about using the PIC10F322 Interrupt. In this post is the the complete code that will use timer0, to replace the __delay_ms() macro. Why would we want to replace the __delay_ms() macro? The macro has some limitations, great if you want to bang something out. However, the macro uses a...

PIC10F322 XC8 Interrupts – Overview

Here is a quick overview of how to get interrupts going in XC8. You will need to define your interrupt function or handler in your code. void __interrupt () isr_routine (void) { } The name isr_routine can be anything you want, however __interrupt () is very important it tells XC8 that this function should be assigned...

PIC10F322 Applications – Cascaded Timer

PIC10F322 Cascaded Timer – when input on PORT.A2 goes low – PORT.A0 will go high, for 1 second, then LOW, Then PORT.A1 will go high, for one second, then LOW. The on time can be changed by adjusting the PulseOut_Time. Of course you can move the input to PORT.A3 and get one more output on PORTA.2 and make it three...

Understanding XC8 MPLAB C Header Files

Received a question about – How to separate a program into multiple files. Simple programs can be put in a single file, but when your program grows larger, while it isn’t impossible to keep it all in one file, it starts to become a big pain in the rear. The purpose of this post is to show you how to move functions...

PIC10F322 Applications – Basic Astable

Continuing with using a PIC10F322 as a 555 replacement – Here is a basic Astable XC code. The output pulses are on PORT.A0 Run down of the code We do some basic setup to get output on Port.A0, Set the speed of the cpu to 16Mhz. The code loop, toggles PORT.A0 on and off. At 16Mhz and no delays, the output pulse is...

PIC10F322 -XC8 – Timer0 Module

The PIC10F322 has two Timer Modules – we are going to take a look at TMR0 (Timer 0). Timer 0 – is an 8bit timer/counter – that can be incremented by either an external signal or internal instruction clock FOSC/4. When the timer overflows – (reaches 0xFF and turns over to 0x00) it sets an interrupt flag that can be...

PIC10F322- XC8 Code – PWM Functions

The PIC10F322 has two PWM modules. The period or frequency of the PWM output is common to all PWM modules, whereas the duty cycle is independently controlled. The two pins where the PWM output is present are: PORT A0 PWM1PORT A1 PWM2 During setup – make sure to set the associated TRIS register and disable analog for...

PIC10F322- XC8 Code – Input or Button Debounce

XC8 Code for PIC10F320 – PIC10F322 – Input or Button Debounce I put together some code to debounce a signal on the inputs of the PIC10F32X device. Switch debouncing is one of those things you generally have to live with when playing with switches and digital circuits. If you want to input a manual switch signal into...

PIC10F322- XC8 Code – WPUA Weak Pull Ups

XC8 Code for PIC10F320 – PIC10F322 – WPUA – XC8 Code – Weak Pull Ups The PIC10F322 has internal Weak Pull Up Resistors on all the GPIO ports. Each one can be individually selected. For those who might not know what an internal weak pull up is – it will tie a pin to positive voltage. Just like adding an external 10K...

PIC10F322 XC8 Code – Clock Reference Output

PIC10F322 XC8 Code – how to get a clock reference output on Port.A2 Reference Clock Output allows you to, basically turn the Port.A2 pin into a clock out device that you can use to drive other devices that require a clock input (think Z80 Clock input). What is nice you can program different clock frequencies . The...

PIC10F322 – XC8 – Simple Traffic Light

Here is a simple traffic light driven by a PIC10F322. After all what model train layout would not be complete without one? The default times are 4 seconds green, 1 second yellow, 4 seconds red. rinse and repeat. Change the timing by updating: define GREEN_TIME 4000 define YELLOW_TIME 1000 define RED_TIME 4000 The...

PIC10F322 – XC8 Code to Blink LED

Blinking a LED on a MCU is much like a “Hello World” program. Here is the XC8 Code and circuit to Blink an LED with a PIC10F322 Micro-controller. The LED is hooked up to PortA0. The code will blink an LED on PortA.0 ever second. The Circuit The Code /* * File: blink_led.c * Author: Jamie Starling - GizoFoundry.com *...

PIC10F322 MCU Overview of The Configuration Bits

What Are the Configuration Bits? They are a collection of special bits that can only be modified at program time. Configuration bits are “read” during reset and enable or disable hardware features in the microcontroller. The features controlled by the configuration bits include, but not limited to, the clock source,...

PIC10F322 XC8 Expanded Header File

Lets make things a little easier on ourselves by defining a standard header file for our PIC10F322 Projects. I named the file 10F322_deviceconfig.h and place it into my XC8 project directory. To use it, I add it to the headers in my XC8 project and include – #include “10F322_deviceconfig.h” in the source file or...

PIC10F322 How to Set a Pin As an Output XC8

The PIC10F322 has 4 general purpose I/O Pins. RA0, RA1, RA2, RA3 – That is assuming you are not using any other peripherals connected to the device and MCLR is disabled. All 4 I/O pins are on the same port – A The registers we need to modify to get a pin into output mode are, ANSELA and TRISA The ANSELA register...