PIC Example Programs

All the following PIC example programs are for the PIC16F1509

https://www.microchip.com/wwwproducts/en/PIC16F1509

The reason I have chosen this chip for my examples is because it’s a versatile 20 pin chip, has all the features you need, SPI, UART, 8 and 16 bit timers.

There are lots of different PIC chips available, I only use the 16F and above, anything lower is not really worth it unless you need a microcontroller for very basic tasks.

The PIC16F1509 features a single UART, SPI and a full 8 bit output port (Port C if you want a full 8 bit port), 4 PWM outputs and a few other little features that we may or may not use.

A note on moving to PIC.. all the familar arduino commands have gone, such as analogWrite(3), serial.Begin(9600) etc. These are libraries that work behind the scenes, with PIC you have to do more yourself working with the registers.. This is a brilliant learning curve.

PIC Example Programs download

I have put together a few downloads of the core things you may want to do with your chip.

UART


This is a basic setup for the serial port, it will repeat any characters back that are recieved.

PWM


Sets the PWM on a pin

Timers


Sets the timer to an interrupt routine

 

These are meant for intermediate electronics programmers, beginners may struggle with the code if not so familiar or used to using the arduino libraries.