User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
439
// Send Low Byte
temp = valueDAC; // Store valueDAC[7..0] to temp[7..0]
SPI2_Write(temp); // Send low byte via SPI
Chip_Select = 1; // Deselect DAC chip
}
void main() {
CHECON = 0x32;
AD1PCFG = 0xFFFF; // Congure AN pins as digital
InitMain(); // Perform main initialization
value = 2048; // When program starts, DAC gives
// the output in the mid-range
while (1) { // Endless loop
if ((RB0_bit) && (value < 4095)) { // If RB0 button is pressed
value++; // increment value
}
else {
if ((RB1_bit) && (value > 0)) { // If RB1 button is pressed
value--; // decrement value
}
}
DAC_Output(value); // Send value to DAC chip
Delay_ms(1); // Slow down key repeat pace
}
}