DESIGN CYCLE
■ SCREENSHOT 4. The Digilent Electronics Explorer's
virtual pushbutton is depressed and the virtual LED
connected to the CLC output displays the logic level
injected into the PIC16LF1507's CLC input by the
pushbutton.
// THIS CONFIGURATION PASSES THE LOGIC LEVEL
// PRESENT AT RC7 TO OUTPUT RA2.
CLC1GLS0 = 0x02;
CLC1GLS1 = 0x00;
CLC1GLS2 = 0x00;
CLC1GLS3 = 0x00;
CLC1SEL0 = 0x01;
CLC1SEL1 = 0x00;
CLC1POL = 0x02;
CLC1CON = 0xC0;
If we want to recall this data using CLC Designer, we
must leave the comments intact. CLC Designer uses some
of the comment information to determine which PIC variant
the code belongs to. Otherwise, the uncommented CLC
register code is all our application source code needs. Now
that we’ve verified our logic using the contents of
Screenshot 3, let’s fire up some electrons and prove out our
logic with hardware and firmware.
Photo 1 includes a PICkit3 acting as a programmer and
the electronic components drawn up in Schematic 1. The
PIC16LF1507 and supporting electronics are built up on a
Digilent Electronics Explorer. The Electronics Explorer allows
us to use virtual pushbuttons and LEDs. Plus, the Explorer
hardware and the WaveForms application combine to form
a self-contained set of test equipment that includes
voltmeters, a four-channel oscilloscope, power supplies,
displays, and a logic analyzer.
I’ve configured the Electronics Explorer’s DIO 0 as a
pushbutton. DIO 1 is set up as a virtual LED. The virtual
pushbutton toggles between a logically low and logically
high state. DIO 0 is wired physically to the PIC16LF1507’s
RC7 I/O pin. So, when the pushbutton in Screenshot 4 is
clicked, a logical high is applied to CLC1 IN1. If our
Screenshot 3 logic assessment is correct, the virtual LED at
DIO 1 connected to the CLC output (I/O pin RA2) will
illuminate when the virtual pushbutton
is depressed. The proof is shown in
Screenshot 4. Here’s the code:
TRISA = 0b11111011;
TRISB = 0b11111111;
//Set CLC input pin (RC7)
TRISC = 0b11111111;
// File: pushbutton-clc.inc
// Generated by CLC Designer, Version: 1.0.0.1
// Date: 12/15/2011 3:30 PM
// Device:PIC16(L)F1507
// INPUT = RC7
// THIS CONFIGURATION PASSES THE LOGIC LEVEL
// PRESENT AT RC7 TO OUTPUT RA2.
CLC1GLS0 = 0x02;
CLC1GLS1 = 0x00;
CLC1GLS2 = 0x00;
CLC1GLS3 = 0x00;
CLC1SEL0 = 0x01;
CLC1SEL1 = 0x00;
CLC1POL = 0x02;
CLC1CON = 0xC0;
}
void main(void)
#include <htc.h>
__CONFIG(FOSC_INTOSC & WDTE_OFF &
BOREN_OFF);
//FUNCTION PROTYPES
void init(void);
//INITIALIZE FUNCTION
void init(void)
{
//Turn off ADC
ADCON0bits.ADON = 0;
ANSELA = 0;
ANSELB = 0;
ANSELC = 0;
//Set CLC output pin (RA2)
■ SCREENSHOT 5. Just a couple
of mouse clicks and some new
comments is all it takes to plug
the NCO into the CLC.
February 2012 55