4.17 NCO - Numerically Controlled Oscillator

4.17.1 Introduction

The MPLAB® Code Configurator (MCC) Melody Numerically Controlled Oscillator Peripheral Library (PLIBs) drivers generates APIs to support NCO-specific peripheral functionality on target MCUs.

The Numerically Controlled Oscillator (NCO) module is a timer that uses overflow from the addition of an increment value to divide the input frequency. The advantage of the addition method over a simple counter driven timer is that the output frequency resolution does not vary with the divider value. The NCO is most useful for applications that require frequency accuracy and fine resolution at a fixed duty cycle.

4.17.2 Supported Device Families

PIC12/16F150x PIC12/16F184x PIC16F153xx
PIC16F171x PIC16F171xx PIC16F180xx
PIC16F181xx PIC16F183xx PIC16F184xx
PIC16F188xx PIC18F-K42 PIC18F-K83
PIC18F-Q24 PIC18F-Q40 PIC18F-Q41
PIC18F-Q43 PIC18F-Q71 PIC18F-Q83
PIC18F-Q84

4.17.3 Required header files


#include "mcc_generated_files/nco/nco[X].h"
Note: Replace [X] with the instance number of the selected NCO module.

4.17.4 Module Documentation

4.17.4.1 NCOx

This file contains the API prototypes for the NCOx driver.

4.17.4.1.1 Module description

This file contains the API prototypes for the NCOx driver.

Version: NCOx Driver Version 2.0.1
Functions
  • void NCOx_Initialize (void)

    Initializes the NCOx module. This routine must be called once before any other NCOx APIs.

  • void NCOx_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the NCOx module interrupts.

  • bool NCOx_GetOutputStatus (void)

    Returns the NCOx output level.

4.17.4.1.2 Function Documentation

NCOx_GetOutputStatus()

bool NCOx_GetOutputStatus (void )

Returns the NCOx output level.

Precondition:

NCOx_Initialize() is already called.

Parameters:
None.
Return values:
1

- Output is high.

0

- Output is low.

NCOx_Initialize()

void NCOx_Initialize (void )

Initializes the NCOx module. This routine must be called once before any other NCOx APIs.

Parameters:
None.
Returns:

None.

NCOx_ISR()

void NCOx_ISR (void )

Implements the Interrupt Service Routine (ISR) for the NCOx module interrupts.

Parameters:
None.
Returns:

None.

4.17.5 File Documentation

4.17.5.1 source/ncox.c File Reference

This file contains the API implementation for the NCOx driver.

#include <xc.h>
#include "../ncox.h"

4.17.5.1.1 Functions

  • void NCOx_Initialize (void)

    Initializes the NCOx module. This routine must be called once before any other NCOx APIs.

  • void NCOx_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the NCOx module interrupts.

  • bool NCOx_GetOutputStatus (void)

    Returns the NCOx output level.

4.17.5.1.2 Detailed Description

This file contains the API implementation for the NCOx driver.

NCOx Generated Driver File.

Version: NCOx Driver Version 2.0.1

4.17.5.2 source/ncox.h File Reference

#include <xc.h>
#include <stdbool.h>
#include <stdint.h>

4.17.5.2.1 Functions

  • void NCOx_Initialize (void)

    Initializes the NCOx module. This routine must be called once before any other NCOx APIs.

  • void NCOx_ISR (void)

    Implements the Interrupt Service Routine (ISR) for the NCOx module interrupts.

  • bool NCOx_GetOutputStatus (void)

    Returns the NCOx output level.

4.17.5.2.2 Detailed Description

NCOx Generated Driver API Header File.