本帖最后由 MianQi 于 2021-8-19 09:55 编辑
这是“main.c”:
- #include "mcc_generated_files/mcc.h"
- uint16_t volatile errVal;
- void ThresholdISR(void);
- /*
- Main application
- */
- void main(void)
- {
- // Initialize the device
- SYSTEM_Initialize();
-
- INTERRUPT_GlobalInterruptEnable();
- //INTERRUPT_PeripheralInterruptEnable();
- ADCC_SetADTIInterruptHandler(ThresholdISR);
- ADCC_DischargeSampleCapacitor();
- ADCC_StartConversion(channel_ANC0);
- // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
- // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global Interrupts
- // Use the following macros to:
- // Enable the Global Interrupts
- //INTERRUPT_GlobalInterruptEnable();
- // Disable the Global Interrupts
- //INTERRUPT_GlobalInterruptDisable();
- while (1)
- {
- // Add your application code
- }
- }
- void ThresholdISR(void)
- {
- errVal = ADCC_GetErrorCalculation();
- PIR1bits.ADIF = 0;
- LATCbits.LATC1 = !LATCbits.LATC1;
- }
|