PIC18 LaurTec Library
3.3.1
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
|
#include <spi.h>
#include <delays.h>
Go to the source code of this file.
Functions | |
void | MCP4822_initialize (unsigned char clock) |
void | MCP4822_set_value (unsigned int value, unsigned char channel) |
void | MCP4822_set_amplitude (unsigned int value, unsigned char channel) |
void | MCP4822_latch_pulse (void) |
void | MCP4822_set_options (unsigned char gain, unsigned char power, unsigned char channel) |
#define initialize_MCP4822 MCP4822_initialize |
#define latch_pulse_MCP4822 MCP4822_latch_pulse |
#define set_amplitude_MCP4822 MCP4822_set_amplitude |
#define set_options_MCP4822 MCP4822_set_options |
#define set_value_MCP4822 MCP4822_set_value |
void MCP4822_initialize | ( | unsigned char | clock | ) |
This function initializes the MCP4822 and PIC signals. SDO, SS, SCK from the PIC side are automatically set by this function.
clock | It sets the clock source for the SPI module. Use the following constants [MCP4822_CLOCK_FOSC_64, MCP4822_CLOCK_FOSC_16, MCP4822_CLOCK_FOSC_4, MCP4822_CLOCK_FOSC_TMR2] |
Definition at line 61 of file MCP4822.c.
References MCP4822_CS_BIT, MCP4822_CS_PORT, MCP4822_CS_TRIS, MCP4822_DAC_A, MCP4822_DAC_B, MCP4822_GAIN_2, MCP4822_LDAC_BIT, MCP4822_LDAC_PORT, MCP4822_LDAC_TRIS, MCP4822_OUT_DEFAULT_VALUE, MCP4822_SCK_BIT, MCP4822_SCK_PORT, MCP4822_SCK_TRIS, MCP4822_SDO_BIT, MCP4822_SDO_PORT, MCP4822_SDO_TRIS, MCP4822_set_amplitude(), MCP4822_set_options(), and MCP4822_SHUTDOWN_ON.
void MCP4822_latch_pulse | ( | void | ) |
This function generates the LATCC pulse required to load the value to the DAC. It is required only in case the MSP4822_set_value is used. The function MSP4822_set_amplitude already include a call to this function.
void |
Definition at line 136 of file MCP4822.c.
References MCP4822_LDAC_BIT, MCP4822_LDAC_PORT, and MCP4822_PULSE_DELAY.
void MCP4822_set_amplitude | ( | unsigned int | value, |
unsigned char | channel | ||
) |
This function sets the output value of the DAC. By Gain 2 the value is expressed in mV, while by Gain 1 is 1/2 mV.
value | It sets the output value of the DAC [12 bits]. |
channel | It sets the channel to which the value refers to [MCP4822_DAC_A, MCP4822_DAC_B]. |
Definition at line 125 of file MCP4822.c.
References MCP4822_latch_pulse(), and MCP4822_set_value().
void MCP4822_set_options | ( | unsigned char | gain, |
unsigned char | power, | ||
unsigned char | channel | ||
) |
This function sets the DAC Options. The options which are set in the function, take place after the next writing to the corresponding DAC Channel.
gain | It sets the output gain [MCP4822_GAIN_1, MCP4822_GAIN_2] |
power | It sets the channel power mode [MCP4822_SHUTDOWN_ON, MCP4822_SHUTDOWN_OFF] |
channel | It sets the channel to which the options refer to [MCP4822_DAC_A, MCP4822_DAC_B] |
Definition at line 149 of file MCP4822.c.
References gain_value_DAC_A_MCP4822, gain_value_DAC_B_MCP4822, MCP4822_DAC_A, MCP4822_DAC_B, power_mode_DAC_A_MCP4822, and power_mode_DAC_B_MCP4822.
void MCP4822_set_value | ( | unsigned int | value, |
unsigned char | channel | ||
) |
This function sets the output value of the DAC. By Gain 2 the value is expressed in mV, while by Gain 1 is 1/2 mV.
value | It sets the output value of the DAC [12 bits]. |
channel | It sets the channel to which the value refers to [MCP4822_DAC_A, MCP4822_DAC_B]. |
Definition at line 94 of file MCP4822.c.
References gain_value_DAC_A_MCP4822, gain_value_DAC_B_MCP4822, MCP4822_CS_BIT, MCP4822_CS_PORT, MCP4822_DAC_A, power_mode_DAC_A_MCP4822, and power_mode_DAC_B_MCP4822.