Hi,
I have modified adc_swtrigger_mpc5748g example.
If "result>threshold", I want to start the timers. But when condition is satisfied, the timer is not ONing. I want to know where I am going wrong.
/* Initialize ADC */
ADC_DRV_Reset(INST_ADCONV1);
ADC_DRV_DoCalibration(INST_ADCONV1);
ADC_DRV_ConfigConverter(INST_ADCONV1,&adConv1_ConvCfg0);
ADC_DRV_EnableChannel(INST_ADCONV1, ADC_CONV_CHAIN_NORMAL, ADC_CHAN_NUM);
/* Start a loop to read converted values and blink an LED */
while(1)
{
ADC_DRV_StartConversion(INST_ADCONV1, ADC_CONV_CHAIN_NORMAL);
while(!(ADC_DRV_GetStatusFlags(INST_ADCONV1) & ADC_FLAG_NORMAL_ENDCHAIN));
uint32_t len = ADC_DRV_GetConvResultsToArray(INST_ADCONV1, ADC_CONV_CHAIN_NORMAL, &result, 1u);
DEV_ASSERT(len == 1u); /* only one value should be read from hardware registers */
(void)len;
ADC_DRV_ClearStatusFlags(INST_ADCONV1, ADC_FLAG_NORMAL_ENDCHAIN);
if (result > ADC_THRESHOLD)
{
PINS_DRV_ClearPins(LED_PORT, (1 << LED));//LED_PORT:PTJ LED:4 on
PINS_DRV_WritePin(PTA,10,1); //off LED
/* Initialize TIMING over PIT */
TIMING_Init(&timing_pal1_instance, &timing_pal1_InitConfig);
/* Get tick resolution in nanosecond unit for TIMING over PIT */
TIMING_GetResolution(&timing_pal1_instance, TIMER_RESOLUTION_TYPE_NANOSECOND, &pitResolution);
/* Start PIT channel 0 counting with the period is 1 second,
the period in tick = the period in nanosecond / PIT tick resolution in nanosecond */
TIMING_StartChannel(&timing_pal1_instance, PIT_CHANNEL, PERIOD_BY_NS/pitResolution);
/* Initialize TIMING over STM */
TIMING_Init(&timing_pal2_instance, &timing_pal2_InitConfig);
/* Get tick resolution in nanosecond unit for TIMING over STM */
TIMING_GetResolution(&timing_pal2_instance, TIMER_RESOLUTION_TYPE_NANOSECOND, &stmResolution);
/* Start STM channel 0 counting with the period is 1 second,
the period in tick = the period in nanosecond / STM tick resolution nanosecond*/
TIMING_StartChannel(&timing_pal2_instance, STM_CHANNEL, PERIOD_BY_NS2/stmResolution);
}
else
{
PINS_DRV_SetPins(LED_PORT, (1 << LED));//off
PINS_DRV_WritePin(PTA,10,0); //on LED
}
}
Thanks!
Krishnaja