Inversion of trigger events for the ADC and HRTIM
Context
While debugging the current measurements of the Twist board, we have noticed that the HRTIM triggered events on the wrong leg (HRTIMA on leg 2 and HRTIMC on leg 1).
Description
The HRTIM and ADC are synchronized by a system of triggers. These triggers are set on both sides with adc1 and adc2 reading triggers from event1 and event3 respectively, as can be seen by this code extract from adc_config.h
void _initialize()
{
if (initialized == 0)
{
// Initialize the ADCs
adc_init();
initialized = 1;
// Perform default configration
configure_adc_trigger_source(1, hrtim_ev1);
configure_adc_trigger_source(2, hrtim_ev3);
configure_adc_trigger_source(3, software);
adc_configure_discontinuous_mode(1, 1);
adc_configure_discontinuous_mode(2, 1);
}
}
From the HRTIM however, the trigger is set at the hrtim_common.c
file. Here we can see this being set for the center aligned application.
void _hrtim_init_events_center_aligned(hrtim_tu_t leg1_tu, hrtim_tu_t leg2_tu)
{
if(leg1_tu == TIMA && leg2_tu == TIMB){
// setting the adc roll-over mode on period event
LL_HRTIM_TIM_SetADCRollOverMode(HRTIM1, LL_HRTIM_TIMER_A, LL_HRTIM_ROLLOVER_MODE_PER);
LL_HRTIM_TIM_SetADCRollOverMode(HRTIM1, LL_HRTIM_TIMER_B, LL_HRTIM_ROLLOVER_MODE_PER);
// setting adc trigger
hrtim_adc_trigger_en(1, 1, LL_HRTIM_ADCTRIG_SRC13_TIMAPER);
hrtim_adc_trigger_en(3, 2, LL_HRTIM_ADCTRIG_SRC13_TIMBPER);
}else if(leg1_tu == TIMA && leg2_tu == TIMC){
// setting the adc roll-over mode on period event
LL_HRTIM_TIM_SetADCRollOverMode(HRTIM1, LL_HRTIM_TIMER_A, LL_HRTIM_ROLLOVER_MODE_PER);
LL_HRTIM_TIM_SetADCRollOverMode(HRTIM1, LL_HRTIM_TIMER_C, LL_HRTIM_ROLLOVER_MODE_PER);
// setting adc trigger
hrtim_adc_trigger_en(1, 1, LL_HRTIM_ADCTRIG_SRC13_TIMAPER);
hrtim_adc_trigger_en(3, 3, LL_HRTIM_ADCTRIG_SRC13_TIMCPER);
}
}
However, this does not work as is because the HRTIMA triggers the adc2 and HRTIMC triggers the adc1.
Solution
We have to find the source of the inversion. Is it an inversion? Or is it so that HRTIMA will always trigger the event 3 and HRTIM C will always trigger the event 1?