dear all,
i try to configure more than two interrupt's adc and ftm for MKE02z64VLC4 controller
FTM interrupt works fine but my ADC interrupt doesn't get triggered , but if configure adc interrupt independently it gets triggered,is it nvic priority issue.
please provide your valuable suggestions ASAP.
Hi
NVIC priorities handle when more than one interrupt occurs at the same time. Priority settings won't explain whey only one interrupt form 2 operates.
More likely you have disabled one interrupt source when enabling the other, or something similar. Read back the NVIC settings to ensure that both are really enabled.
Regards
Mark
Hi Mark,
thanks for your quick response,below is the code for configuring adc and ftm , i have compiled the code using IAR ,any issues in the below code.
#undef VECTOR_035
#define VECTOR_035 FTM2_Isr
#undef VECTOR_031
#define VECTOR_031 ADC_Isr
extern void ADC_Isr(void);
extern void FTM2_Isr(void);
int main(void)
{
ftm_init();
adc_init();
while(1)
{
]
}
void FTM2_Task(void)
{
LED0_Toggle();
}
void ADC_CallBack( void )
{
LED0_Toggle(); /*!< toggle LED1 */
}
regards,
Lavakush
void ftm_init(void)
{
SIM_RemapFTM2CH1Pin();
SIM_RemapFTM2CH0Pin();
/* FTM2 is set as edge aligned pwm mode, high true pulse */
FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE);
/* FTMEN enable */
FTM_SetFTMEnhanced(FTM2);
/* update MOD value */
FTM_SetModValue(FTM2, 9999);
/* set clock source, start counter */
FTM_ClockSet(FTM2, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV1);
/* enable FTM2 interrupt in NVIC */
NVIC_EnableIRQ(FTM2_IRQn);
/* setup call back function for interrupt */
FTM_SetCallback(FTM2, FTM2_Task);
/* enable FTM2 overflow interrupt */
FTM_EnableOverflowInt(FTM2);
}
void adc_init(void)
{
sADC_Config.u8ClockDiv = ADC_ADIV_DIVIDE_4;
sADC_Config.u8ClockSource = CLOCK_SOURCE_BUS_CLOCK;
sADC_Config.u8Mode = ADC_MODE_12BIT;
sADC_Config.sSetting.bIntEn = 1;
ADC_SetCallBack(ADC_CallBack);
data=NVIC_GetPriority(ADC0_IRQn);
ADC_Init( ADC, &sADC_Config);
}
Hi
I see that the FTM interrupt is enabled using NVIC_EnableIRQ(FTM2_IRQn);
Shouldn't there be a similar call for the ADC?
Regards
Mark
hi mark,
i have enabled my interrupt by setting sADC_Config.sSetting.bIntEn = 1; below function takes care of calling NVIC_EnableIRQ() function
void ADC_Init(ADC_Type *pADC, ADC_ConfigTypePtr pADC_Config)
{
if( pADC == ADC)
{
SIM->SCGC |= SIM_SCGC_ADC_MASK;
}
/* set clock cource for ADC */
ADC_SelectClock(pADC,pADC_Config->u8ClockSource);
/* set clock divide */
ADC_SelectClockDivide(pADC,pADC_Config->u8ClockDiv);
/* set ADC mode */
ADC_SetMode(pADC,pADC_Config->u8Mode);
/* set FIFO level */
ADC_SetFifoLevel(pADC,pADC_Config->u8FiFoLevel);
/* set pin control */
pADC->APCTL1 = pADC_Config->u16PinControl;
if( pADC_Config->sSetting.bCompareEn )
{
ADC_CompareEnable(pADC);
}
if( pADC_Config->sSetting.bCompareGreaterEn )
{
ADC_CompareGreaterFunction(pADC);
}
if( pADC_Config->sSetting.bContinuousEn )
{
ADC_ContinuousConversion(pADC);
}
if( pADC_Config->sSetting.bCompareAndEn )
{
ADC_CompareFifoAnd(pADC);
}
if( pADC_Config->sSetting.bFiFoScanModeEn )
{
ADC_FifoScanModeEnable(pADC);
}
if( pADC_Config->sSetting.bHardwareTriggerEn )
{
ADC_SetHardwareTrigger(pADC);
}
if( pADC_Config->sSetting.bIntEn )
{
ADC_IntEnable(pADC);
NVIC_EnableIRQ( ADC0_IRQn );
}
if( pADC_Config->sSetting.bLongSampleEn )
{
ADC_SetLongSample(pADC);
}
if( pADC_Config->sSetting.bLowPowerEn )
{
ADC_SetLowPower(pADC);
}
#if !defined(CPU_KE02)
if( pADC_Config->sSetting.bHTRGMEn )
{
ADC_HardwareTriggerMultiple(pADC);
}
else
{
ADC_HardwareTriggerSingle(pADC);
}
if( pADC_Config->sSetting.bHTRGMASKEn )
{
ADC_HardwareTriggerMaskEnable(pADC);
}
else
{
ADC_HardwareTriggerMaskDisable(pADC);
}
if( pADC_Config->sSetting.bHTRGMASKSEL )
{
ADC_HardwareTriggerMaskAuto(pADC);
}
else
{
ADC_HardwareTriggerMaskNonAuto(pADC);
}
#endif
}
Hi lavakush,
Not setting the priority for interrupts can also cause such issues. The other reason might be that NMI pin is not disabled. By default NMI pin is enabled. Processor expert has a setting to disable NMI setting. But if you are developing a baremetal code, this needs to be disabled during initialization.