hi i need to configure 2 adc channel of adc channel 0 and as well as adc channel 12 through interrup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

hi i need to configure 2 adc channel of adc channel 0 and as well as adc channel 12 through interrup

445 Views
sandeep_c
Contributor I

hi i need to configure 2 adc channel of adc channel 0 and as well as adc channel 12 through interrupt based but i didnt get the output for two channels 

1)
#include "sdk_project_config.h"
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "interrupt_manager.h"
#include "helper_functions.h"
 
volatile int exit_code = 0;
volatile bool adcConvDone;
volatile uint16_t adcRawValue,adcRawValue1;
 
/* User includes */
#define ADC_INSTANCE    0UL
#define ADC_CHN         ADC_INPUTCHAN_EXT12
#define ADC_VREFH       5.0f
#define ADC_VREFL       0.0f
#define PDB_INSTANCE    0UL
#define PDLY_TIMEOUT    1000000UL
 
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
void clock_pins_init(void)
{
CLOCK_DRV_Init(&clockMan1_InitConfig0);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
}
void ADC_IRQHandler(void)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(ADC_INSTANCE, 0U, (uint16_t *)&adcRawValue);
ADC_DRV_GetChanResult(ADC_INSTANCE, 1U, (uint16_t *)&adcRawValue1);
 
/* Set ADC conversion complete flag */
adcConvDone = true;
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
 
}
void adc_init(void)
{
ADC_DRV_ConfigConverter(0, &adc0_conveter);
ADC_DRV_AutoCalibration(0);
ADC_DRV_ConfigChan(0, 0, &adc_config_1_ChnConfig0);
ADC_DRV_ConfigChan(0, 1, &adc_config_1_ChnConfig1);
INT_SYS_InstallHandler(ADC0_IRQn, &ADC_IRQHandler, (isr_t*) 0);
 
}
 
void pdc_config(void)
{
uint32_t delay;
if (!calculateIntValue(&pdb_config_1_timerConfig0, PDLY_TIMEOUT, &delay))
{
/* Stop the application flow */
while(1);
}
PDB_DRV_Init(0, &pdb_config_1_timerConfig0);
PDB_DRV_Enable(0);
PDB_DRV_ConfigAdcPreTrigger(0, 0, &pdb_config_1_adcTrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(0, 0, &pdb_config_1_adcTrigConfig0);
 
PDB_DRV_SetTimerModulusValue(0,(uint32_t) delay);
 
PDB_DRV_SetAdcPreTriggerDelayValue(0, 0, 0, delay);
PDB_DRV_SetAdcPreTriggerDelayValue(0, 1, 1, delay);
 
PDB_DRV_LoadValuesCmd(PDB_INSTANCE);
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
/* Enable ADC 1 interrupt */
INT_SYS_EnableIRQ(ADC0_IRQn);
 
}
int main(void)
{
/* Write your code here */
clock_pins_init();
adc_init();
pdc_config();
 
while(1);
}
 
/* END main */
/*!
 ** @}
 */
 
2)
 
#include "sdk_project_config.h"
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "interrupt_manager.h"
#include "helper_functions.h"
 
volatile int exit_code = 0;
volatile bool adcConvDone;
volatile uint16_t adcRawValue,adcRawValue1;
 
/* User includes */
#define ADC_INSTANCE    0UL
#define ADC_CHN         ADC_INPUTCHAN_EXT12
#define ADC_VREFH       5.0f
#define ADC_VREFL       0.0f
#define PDB_INSTANCE    0UL
#define PDLY_TIMEOUT    1000000UL
 
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
void clock_pins_init(void)
{
CLOCK_DRV_Init(&clockMan1_InitConfig0);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
}
void ADC_IRQHandler(void)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(ADC_INSTANCE, 0U, (uint16_t *)&adcRawValue);
ADC_DRV_GetChanResult(ADC_INSTANCE, 1U, (uint16_t *)&adcRawValue1);
 
/* Set ADC conversion complete flag */
adcConvDone = true;
 
}
void adc_init(void)
{
ADC_DRV_ConfigConverter(0, &adc0_conveter);
ADC_DRV_AutoCalibration(0);
ADC_DRV_ConfigChan(0, 0, &adc_config_1_ChnConfig0);
ADC_DRV_ConfigChan(0, 1, &adc_config_1_ChnConfig1);
INT_SYS_InstallHandler(ADC0_IRQn, &ADC_IRQHandler, (isr_t*) 0);
}
 
void pdc_config(void)
{
uint32_t delay=1;
if (!calculateIntValue(&pdb_config_1_timerConfig0, PDLY_TIMEOUT, &delay))
{
/* Stop the application flow */
while(1);
}
PDB_DRV_Init(0, &pdb_config_1_timerConfig0);
PDB_DRV_Enable(0);
 
PDB_DRV_ConfigAdcPreTrigger(0, 0, &pdb_config_1_adcTrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(0, 1, &pdb_config_1_adcTrigConfig1);
 
PDB_DRV_SetTimerModulusValue(0,(uint32_t) delay);
 
PDB_DRV_SetAdcPreTriggerDelayValue(0, 0, 0,  (uint32_t)delay);
 
PDB_DRV_LoadValuesCmd(PDB_INSTANCE);
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
/* Enable ADC 1 interrupt */
INT_SYS_EnableIRQ(ADC0_IRQn);
 
}
int main(void)
{
/* Write your code here */
clock_pins_init();
adc_init();
pdc_config();
 
while(1)
{
if (adcConvDone == true)
{
adcConvDone = false;
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
}
}
}
 
/* END main */
/*!
 ** @}
 */

 

 

0 Kudos
3 Replies

433 Views
sandeep_c
Contributor I
iam not getting will i get the interrupt for each channel conversion or completing of channles conversion example completing ch1 intr, ch2 seperate interrupt or for ch1 and ch2 is one interrupt.
0 Kudos

398 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

I don't think you need to enable interrupts for all ADC channels, you only need to enable interrupt for the last ADC channel. When the last ADC channel is interrupted, all ADC channels should have been converted, and you can directly read the results of all ADC channels. 

For example: enable the interrupt of ADC channel (adc_config_1_ChnConfig1).

Best Regards,
Robin

0 Kudos

378 Views
sandeep_c
Contributor I
i tried with enabling the channel last pin it means 15 th pin of adc but i didnt get any interrupt
0 Kudos