In this project, the NCO peripheral generates a square-wave with variable frequency in the audible spectrum. The POT1 potentiometer on the Curiosity Board adjusts the frequency. The potentiometer is read using the Analog-to-Digital Converter (ADC) peripheral.
- MPLAB® X IDE v6.15 or newer
- MPLAB® XC8 v2.45 or newer
- PIC16F1xxxx_DFP v1.21.368
-
BUZZ CLICK board™ (mikroBUS™ socket 1):
To program the microcontroller with this MPLAB X project, follow the steps provided in the How to Program the Microcontroller chapter.
The following configurations must be made for this project:
-
Clock Control:
- Clock Source: HFINTOSC
- HF Internal Clock: 32 MHz
- Clock Divider: 4
-
Configuration bits:
- WDT operating mode: WDT disabled
-
NCO1:
- Enable NCO: Yes
- NCO Mode: FDC mode
- Output polarity: Active high
- Clock Source: FOSC
- Requested NCO Output Frequency: 1000 Hz
-
ADCC:
- Enable ADC: Yes
- Operating Mode: Basic mode
- Result Alignment: Right
- Positive Input Channel: ANC0
- Positive Reference: VDD
- Negative Reference: VSS
- Auto-conversion Trigger: Disabled
- Acquisition Count: 1
- Clock Source: FOSC
- Clock Divider: FOSC/32
Pin | Configuration | Description |
---|---|---|
RC0 | Analog input | Potentiometer |
RC5 | Digital output | Buzzer |
Board setup:
This code example shows how to make a tone generator using the NCO and ADC peripherals.
This chapter demonstrates how to use the MPLAB X IDE to program a PIC® device with an Example_Project.X
. This applies to other projects.
-
Connect the Curiosity Development board to the PC.
-
Open the
Example_Project.X
project in MPLAB X IDE. -
Set the
Example_Project.X
project as main project.
Right click the project in the Projects tab and then Set as Main Project. -
Clean and build the
Example_Project.X
project.
Right click theExample_Project.X
project and select Clean and Build. -
Select Starter Kits (PKOB) in the Connected Hardware Tool section of the project settings:
Right click the project and Properties.
Click the arrow under the Connected Hardware Tool, and from the dropdown, select Starter Kits (PKOB) by clicking the SN.
Click Apply and then OK. -
Program the project to the microcontroller.
Right click the project and then Make and Program Device.