ThanosTheAvenger
Newbie level 4
This is the generated code from MCC...
This is main...
Now, whether or not MCU pins are reading analog voltages properly, the Interrupt has to be generated.
But, the breakpoint when set in the ADC1Interrupt function is never hit.
Please help me.
Code:
void ADC1_Initialize (void)
{
// ASAM disabled; DMABM disabled; ADSIDL disabled; DONE disabled; DMAEN disabled; FORM Absolute decimal result, unsigned, right-justified; SAMP disabled; SSRC Clearing sample bit ends sampling and starts conversion; MODE12 12-bit; ADON enabled;
AD1CON1 = 0x8400;
// CSCNA disabled; NVCFG0 AVSS; PVCFG AVDD; ALTS disabled; BUFM disabled; SMPI 8; OFFCAL disabled; BUFREGEN disabled;
AD1CON2 = 0x001C;
// SAMC 8; EXTSAM disabled; PUMPEN disabled; ADRC FOSC/2; ADCS 7;
AD1CON3 = 0x0807;
// CH0SA AN1; CH0SB AN1; CH0NB AVSS; CH0NA AVSS;
AD1CHS = 0x0101;
// CSS31 disabled; CSS30 disabled; CSS29 disabled; CSS28 disabled; CSS27 disabled;
AD1CSSH = 0x0000;
// CSS9 disabled; CSS7 disabled; CSS6 disabled; CSS5 disabled; CSS4 disabled; CSS3 disabled; CSS2 disabled; CSS1 disabled; CSS14 disabled; CSS0 disabled; CSS13 disabled; CSS12 disabled; CSS11 disabled; CSS10 disabled;
AD1CSSL = 0x0000;
// VBG2EN disabled; VBGEN disabled;
ANCFG = 0x0000;
AD1CON2bits.SMPI = 1;
adc1_obj.intSample = AD1CON2bits.SMPI;
ADC1_ChannelSelect(1);
ADC1_Start();
// Enabling ADC1 interrupt.
IEC0bits.AD1IE = 1;
}
void ADC1_Start(void)
{
AD1CON1bits.SAMP = 1;
}
void ADC1_Stop(void)
{
AD1CON1bits.SAMP = 0;
}
uint16_t ADC1_ConversionResultBufferGet(uint16_t *buffer)
{
int count;
uint16_t *ADC16Ptr;
ADC16Ptr = (uint16_t *)&(ADC1BUF0);
for(count=0;count<=adc1_obj.intSample;count++)
{
buffer[count] = (uint16_t)*ADC16Ptr;
ADC16Ptr++;
}
return count;
}
uint16_t ADC1_ConversionResultGet(void)
{
return ADC1BUF0;
}
bool ADC1_IsConversionComplete( void )
{
return AD1CON1bits.DONE; //Wait for conversion to complete
}
void ADC1_ChannelSelect( ADC1_CHANNEL channel )
{
AD1CHS = channel;
}
void __attribute__ ( ( __interrupt__ , auto_psv ) ) _ADC1Interrupt ( void )
{
// clear the ADC interrupt flag
IFS0bits.AD1IF = false;
}
This is main...
Code:
int main(void)
{
// initialize the device
SYSTEM_Initialize();
while (1)
{
// Add your application code
}
return -1;
}
void SYSTEM_Initialize(void)
{
PIN_MANAGER_Initialize();
INTERRUPT_Initialize();
OSCILLATOR_Initialize();
ADC1_Initialize();
}
Now, whether or not MCU pins are reading analog voltages properly, the Interrupt has to be generated.
But, the breakpoint when set in the ADC1Interrupt function is never hit.
Please help me.