ADC cann't enter interrupt

cancel
Showing results for 
Search instead for 
Did you mean: 

ADC cann't enter interrupt

126 Views
wqiang19
Contributor I

Hi,

why i cann't enter interrupt.  @  SC1A's  AIEN=1&coco=1

void ADC0_IRQHandler(void)
{
int i=0;
i++;
print(welcomeStr);
}
void ADC1_IRQHandler(void)
{
int i=0;
i++;
print(welcomeStr);
}
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
int main(void)
{
/* Enable the floating point unit */
enableFPU();

/* Write your local variable definition here */
/* Variables in which we store data from ADC */
uint16_t adcRawValue;
uint16_t adcMax;
float adcValue;

/* Buffer used to store processed data for serial communication */
char msg[255] =
{ 0, };

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Write your code here */
/* For example: for(;;) { } */

/* Initialize and configure clocks
* - see clock manager component for details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

/* Get ADC max value from the resolution */
if (adConv1_ConvConfig0.resolution == ADC_RESOLUTION_8BIT)
adcMax = (uint16_t) (1 << 8);
else if (adConv1_ConvConfig0.resolution == ADC_RESOLUTION_10BIT)
adcMax = (uint16_t) (1 << 10);
else
adcMax = (uint16_t) (1 << 12);

/* Initialize LPUART instance
* - See LPUART component for configuration details
* If the initialization failed, break the program
*/
if (LPUART_DRV_Init(INST_LPUART1, &lpuart1_State, &lpuart1_InitConfig0)
!= STATUS_SUCCESS)
__asm("bkpt #255");

/* Configure and calibrate the ADC converter
* - See ADC component for the configuration details
*/
ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
ADC_DRV_AutoCalibration(INST_ADCONV1);

ADC_DRV_ConfigHwCompare(INST_ADCONV1,&adConv1_HwCompConfig0);//coco自动清0

/* Send a welcome message via LPUART */
print(welcomeStr);

/* Infinite loop:
* - Trigger a new conversion
* - Wait and get the result
* - Make the value more user friendly
* - Send the data to LPUART
*/

while (1)
{
/* Configure ADC channel and software trigger a conversion */
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);//AIEN set 同时coco set
/* Wait for the conversion to be done */
// ADC_DRV_WaitConvDone(INST_ADCONV1);
/* Store the channel result into a local variable */
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRawValue);

/* Process the result to get the value in volts */
adcValue = ((float) adcRawValue / adcMax) * (ADC_VREFH - ADC_VREFL);
/* And convert it to string */
floatToStr(&adcValue, msg, 5);

/* Send the result to the user via LPUART */
print(headerStr);
print(msg);
print(" V\r\n");

/* Do nothing for a number of cycles */
delayCycles(0x7FFFFF);
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the Freescale S32K series of microcontrollers.
**
** ###################################################################
*/

0 Kudos
1 Reply

50 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi wang qiang ,

  Which detail kinetis chip are you are using now?

  Please tell me your kinetis chip part number, then I can help you to check the details.

  When you want to enable the ADC interrupt, you need to configure the ADC IRQ, enable it, and enable the global interrupt.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------