i configured adc mutiple channe as below but i iam not receiving interrupt from adc0

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

i configured adc mutiple channe as below but i iam not receiving interrupt from adc0

248 Views
sandeepc
Contributor IV

hi i need read 24 channels for my end applicaton as of now iam trying to read 2 channels if i am done with adc 2 channels so that i can understand to do 24 channles 

SDK DETAILS

S32 Design Studio for S32 Platform
Version: 3.4
Build id: 201217 (Update 3)

as of now iam configured as below

adc converter config and channels PTA 0 AND PTC14

const adc_converter_config_t adc_config_1_ConvConfig0 = {
.clockDivide = ADC_CLK_DIVIDE_4,
.sampleTime = 255U,
.resolution = ADC_RESOLUTION_12BIT,
.inputClock = ADC_CLK_ALT_1,
.trigger = ADC_TRIGGER_HARDWARE,
.pretriggerSel = ADC_PRETRIGGER_SEL_PDB,
.triggerSel = ADC_TRIGGER_SEL_PDB,
.dmaEnable = false,
.voltageRef = ADC_VOLTAGEREF_VREF,
.continuousConvEnable = false,
.supplyMonitoringEnable = false
};

const adc_chan_config_t adc_config_1_ChnConfig0 = {
.interruptEnable = true,
.channel = ADC_INPUTCHAN_EXT12
};

const adc_chan_config_t adc_config_1_ChnConfig1 = {
.interruptEnable = true,
.channel = ADC_INPUTCHAN_EXT0
};

 

PDB CONFIG 

/*! @brief ADC pre-trigger configurations */
const pdb_adc_pretrigger_config_t pdb_config_1_adcTrigConfig0 = {
.adcPreTriggerIdx = 0U,
.preTriggerEnable = true,
.preTriggerOutputEnable = true,
.preTriggerBackToBackEnable = false
};

const pdb_adc_pretrigger_config_t pdb_config_1_adcTrigConfig1 = {
.adcPreTriggerIdx = 1U,
.preTriggerEnable = true,
.preTriggerOutputEnable = true,
.preTriggerBackToBackEnable = true
};


/*! @brief PDB timer configurations */
const pdb_timer_config_t pdb_config_1_timerConfig0 = {
.loadValueMode = PDB_LOAD_VAL_IMMEDIATELY,
.seqErrIntEnable = false,
.clkPreDiv = PDB_CLK_PREDIV_BY_128,
.clkPreMultFactor = PDB_CLK_PREMULT_FACT_AS_10,
.triggerInput = PDB_SOFTWARE_TRIGGER,
.continuousModeEnable = false,
.dmaEnable = false,
.intEnable = false,
.instanceBackToBackEnable = false,
};

 

HERE IS THE MAIN CODE

/*!
 ** Copyright 2020 NXP
 ** @file main.c
 ** @brief
 **         Main module.
 **         This module contains user's application code.
 */
/*!
 **  @addtogroup main_module main module documentation
 **  @{
 */
/* MODULE main */
 
 
/* Including necessary configuration files. */
#include "sdk_project_config.h"
#include "interrupt_manager.h"
#include "helper_functions.h"
volatile bool adcConvDone;
 
volatile int exit_code = 0;
/* User includes */
#define PDB_INSTANCE 0
#define ADC_INSTANCE 0
#define PDLY_TIMEOUT    1000000UL
IRQn_Type adcIRQ;
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
uint16_t adcRawValue,adcRawValue1;
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 clock_pins(void)
{    status_t status;
 
status = CLOCK_DRV_Init(&clockMan1_InitConfig0);
DEV_ASSERT(status == STATUS_SUCCESS);
 
/* Set pins as GPIO */
status = PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
DEV_ASSERT(status == STATUS_SUCCESS);
}
void adc0(void)
{
 
 
switch(ADC_INSTANCE)
{
case 0UL:
adcIRQ = ADC0_IRQn;
break;
case 1UL:
adcIRQ = ADC1_IRQn;
break;
default:
adcIRQ = ADC1_IRQn;
break;
}
ADC_DRV_ConfigConverter(ADC_INSTANCE, &adc_config_1_ConvConfig0);
ADC_DRV_AutoCalibration(ADC_INSTANCE);
 
 
 
ADC_DRV_ConfigChan(ADC_INSTANCE, 0UL, &adc_config_1_ChnConfig1);
ADC_DRV_ConfigChan(ADC_INSTANCE, 1UL, &adc_config_1_ChnConfig0);
 
INT_SYS_InstallHandler(adcIRQ, &ADC_IRQHandler, (isr_t*) 0);
 
}
 
void pdb0(void)
{
 
uint16_t delayValue;
if (!calculateIntValue(&pdb_config_1_timerConfig0, PDLY_TIMEOUT, &delayValue))
{
/* Stop the application flow */
while(1);
}
PDB_DRV_Init(PDB_INSTANCE, &pdb_config_1_timerConfig0);
PDB_DRV_Enable(PDB_INSTANCE);
 
PDB_DRV_ConfigAdcPreTrigger(PDB_INSTANCE, 0UL, &pdb_config_1_adcTrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(PDB_INSTANCE, 0UL, &pdb_config_1_adcTrigConfig1);
 
 
PDB_DRV_SetTimerModulusValue(PDB_INSTANCE, (uint32_t) delayValue);
 
 
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 0UL, 0UL,(uint32_t) delayValue);
 
 
PDB_DRV_LoadValuesCmd(PDB_INSTANCE);
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
 
/* Enable ADC 1 interrupt */
INT_SYS_EnableIRQ(adcIRQ);
 
}
int main(void)
{
/* Write your code here */
clock_pins();
adc0();
pdb0();
while(1)
{
if(adcConvDone)
{
adcConvDone = false;
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
}
 
}
return exit_code;
}
 
/* END main */
/*!
 ** @}
 */

@S32K_tj @S32kUser 

0 Kudos
1 Reply

211 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi sandeepc,

When debugging the project, setting a breakpoint in ADC_IRQHandler cannot pause it?
By they way, have you refer to those examples?
Example S32K148 PDB0-PDB1 ring S32DS3.4 RTM4.0.3
Example S32K148 PDB0-PDB1 ring DMA S32DS3.4 RTM4.0.3


Best Regards,
Robin
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------

0 Kudos