SOURCES
Microchip
PIC16(L)F1507
HI-TECH C Compiler for
PIC10/12/16 MCUs
PICkit3
MPLAB IDE
www.microchip.com
Digilent, Inc.
Electronics Explorer
www.digilentinc.com
0x1000. We don’t have to do
much to generate that square
wave. Flip the mode bit, set the
Ripple Counter runout, and load
the Increment Register:
■ SCREENSHOT 7. Figures don't lie.
NCO1CONbits.N1PFM = 1;
//Change mode to PF
is gated to the Ripple Counter input and the Ripple Counter
begins to count. The NCO output is logically high at this point.
For the NCO to generate a valid pulse in PF mode, the
accumulator overflow must not occur before the Ripple Counter
completes its count sequence. When the Ripple Counter
reaches maximum count, it resets the SR Latch forcing Q
logically low. At this point, the Ripple Counter is reset by the
output and the Ripple Counter count is inhibited. The output
of the NCO will remain logically low until the accumulator
overflows again. To generate that square wave, we will need
the accumulator to overflow every 16 µS. The frequency
associated with 16 µS is 62. 5 kHz. Once again, we must use
our FOVERFLOW formula to solve for Increment Value:
Increment Value = (1,048,576 x (62.5 KHz)) / 16 MHz
The Increment Value computes to 4,096, which is
NCO1CLKbits.N1PWS2 = 1;
NCO1CLKbits.N1PWS1 = 1;
NCO1CLKbits.N1PWS0 = 1;
//Ripple Counter set
//for 128 clock
//cycles
NCO1INCH = 0x10;
//Increment Register
//loaded with 0x1000
NCO1INCL = 0x00;
You can view our square wave in Screenshot 7.
WHEN YOU’RE DONE
The PIC16(L)F1507 is an extended midrange
microcontroller. When you’ve finished exploring all of the
ins and outs of the NCO and CLC, you can move on to
the other PIC16(L)F1507 features and peripherals. Then,
add the PIC16(L)F1507 to your Design Cycle. NV
PICBASIC PRO™ Compiler
PBP
Experimenter - $49.95
Silver Edition - $119.95
Gold Edition - $269.95
The industry-standard BASIC compiler for Microchip PIC® microcontrollers.
Multi-Seat Licensing
for Educational Institutions
Upgrade from
PICBASIC™ Compiler (PBC)
Download a FREE trial version now.
www.PBP3.com
www.melabs.com microEngineering Labs, Inc. 888-316-1753
PICBASIC and PICBASIC PRO are trademarks of Microchip Technology Inc. in the USA and other countries. PIC is a registered trademark of Microchip Technology Inc. in the USA and other countries.
58
February 2012