21,14 → 21,26 |
FVRCONbits.CDAFVR = 0b01; // Gain of 1x (1.024V) |
FVRCONbits.FVREN = 1; // Enable FVR module |
|
/* Initialize DAC for the lower threshold (Ref-) */ |
/* Initialize DAC for the lower threshold (Ref-) to Vss */ |
DACCON0bits.DACEN = 0; // Disable DAC |
DACCON0bits.DACLPS = 0; // Negative reference source selected |
DACCON0bits.DACOE = 0; // Output not routed to DACOUT pin |
DACCON0bits.DACPSS = 0b00; // Vdd used as positive source |
DACCON0bits.DACPSS = 0b00; // Vss used as positive source |
// DACCON0bits.DACNSS = 0; // Vss used as negative source |
DACCON1bits.DACR = 0b00000; // Voltage output set to 0 |
// Output voltage formula: |
// V_out = ((V_source+ - V_source-) * (DACR / 32)) + V_source- |
DACCON1bits.DACR = 0b00000; // Voltage output set to 0v |
|
// /* Initialize DAC for the lower threshold (Ref-) to variable setting */ |
// DACCON0bits.DACEN = 1; // Enable DAC |
// DACCON0bits.DACLPS = 1; // Positive reference source selected |
// DACCON0bits.DACOE = 0; // Output not routed to DACOUT pin |
// DACCON0bits.DACPSS = 0b10; // FVR buffer2 used as positive source |
//// DACCON0bits.DACNSS = 0; // Vss used as negative source |
// // Output voltage formula: |
// // V_out = ((V_source+ - V_source-) * (DACR / 32)) + V_source- |
// DACCON1bits.DACR = 0b10000; // Voltage output set to 0.512v |
|
/* Initialize Timer 0 */ |
OPTION_REGbits.TMR0CS = 0; // Clock source is FOSC/4 |
OPTION_REGbits.PSA = 0; // Prescaler enabled |
86,9 → 98,10 |
/CPS_AVG_COUNT; |
// Set flag to indicate that button is not pressed |
cps_data_p->btn_pressed[cps_data_p->channel] = 0; |
} else if (percent > CPS_PCT_ON) |
} else if (percent > CPS_PCT_ON) { |
// Set flag to indicate that button was pressed |
cps_data_p->btn_pressed[cps_data_p->channel] = 1; |
} |
|
cps_data_p->channel = cps_data_p->channel + 1; |
if (cps_data_p->channel == CPS_NUM_CHANNELS) |