Tutorial 17: Frequency generator using Compare Special Trigger

A frequency generator is created using the Compare special trigger mode

Description

In Tutorial 10, a repeating frequency was created by calculating the overflow offset for Timer1. Using the special Trigger mode of the Compare module is a simpler method of generating a 16 bit time base frequency. The 16 bit period of the desired frequency is entered into PORTB,PORTC and a scalor is selected for Timer1 using Bits, 6,7 of PortD, where 00 = 1:1, 01 = 1:2, 10 = 1:4, 11 = 1:8. TIMER1 then increments until it matches the 16 bit value on PortCD whereby it then resets to zero and generates an interrupt to read the current value on PortCD. This very simple method generates a signal of frequency 2/Period

Download FEATURE877_Tutorial17.zip and unzip into folder <your path>\Tutorial 17

Filename Version Description
tut17.pjt 1.0 MPLAB Project
tut17.asm 1.0 PIC16F877 Assembler code
tut17.hex 1.0 Precompiled HEX
tut17.lst 1.0 Precompiled LST
tut17.vbb 1.0 Virtual Breadboard simulation

 

Demonstrates

CCP1 Special Trigger

TIMER1