Cpu Clock Source - Digilent Cerebot MC7 Reference Manual

Hide thumbs Also See for Cerebot MC7:
Table of Contents

Advertisement

Cerebot MC7™ Board Reference Manual
12 User I/O Devices
The Cerebot MC7 board provides two push button switches for user input and four discrete LEDs for output. The
buttons, BTN1 and BTN2 are connected to I/O pins RB8 and RB14 respectively. To read the buttons, bits 8 and/or
14 of PORTB must be set as inputs by setting the corresponding bits in the TRISB register and then reading the
PORTB register. When a button is pressed, the corresponding bit will be high ('1').
The four LEDs are connected to bits 4-7 of PORTD. LED 1 is connected to bit 4, LED 2 is connected to bit 5, and so
on. To use the LEDs, set the desired bits as outputs by clearing the corresponding bits in the TRISD register and set
the bits to the desired value in the PORTD or LATD register. Setting a bit to 1 will illuminate the LED and setting the
bit to 0 will turn it off.
Note that PORTD bits 4-7 are also used by Pmod connector JC and by four of the RC servo connectors.

13 CPU Clock Source

The dsPIC microcontroller on the Cerebot MC7 supports numerous clock source options for the main processor
operating clock. The Cerebot MC7 board provides an external 8Mhz crystal for use with the XT oscillator option.
This crystal is on the bottom of the board. Oscillator options are selected via configuration macros supplied as part
of the Microchip C30 compiler suite for the dsPIC.
In addition to the crystal oscillator using the external 8Mhz, the dsPIC microcontroller also has an internal 8Mhz RC
oscillator. It also provides the capability to switch clock source and clock speed during operation.
Using the internal system clock phase-locked loop (PLL), it is possible to select numerous multiples or divisions of
the 8Mhz oscillator to produce CPU operating frequencies up to 40Mhz. The operating frequency can be selected
using configuration macros. Refer to section 9.1 CPU Clocking System in the data sheet for the
dsPIC33FJXXXMCX06A/X08A/X10A family devices for information on how to set up the clock source and operating
frequency.
The following example code will set the clocking options for operation at 40 MIPS.
/* The settings below set up the oscillator and PLL for 40 MIPS as
**follows:
**
Crystal Frequency
** Fcy =
---------------------------------
**
** Crystal
= Defined in UserParms.h
** Fosc
** Fcy
*/
PLLFBD = (int)(40 - 2);
CLKDIVbits.PLLPOST = 0;
CLKDIVbits.PLLPRE = 0;
__builtin_write_OSCCONH(0x03);
__builtin_write_OSCCONL(0x01);
while(OSCCONbits.COSC != 0b011);
// Wait for PLL to lock
while(OSCCONbits.LOCK != 1);
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
* (DIVISOR+2)
PLLPOST * (PRESCLR+2) * 4
= Crystal * dPLL defined in UserParms.h
= DesiredMIPs
// N1=2
// N2=2
Page 11 of 22

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Cerebot MC7 and is the answer not in the manual?

Table of Contents