Skip to content
Snippets Groups Projects
Commit 30ae35ab authored by Luiz Fernando Lavado Villa's avatar Luiz Fernando Lavado Villa :speech_balloon:
Browse files

Implements the triggering moment for the adc, changes the adc conversion time

parent 71ec65cc
No related branches found
No related tags found
1 merge request!16Implements the triggering moment for the adc, changes the adc conversion time
...@@ -377,7 +377,7 @@ void adc_channels_configure(uint8_t adc_num) ...@@ -377,7 +377,7 @@ void adc_channels_configure(uint8_t adc_num)
*/ */
LL_ADC_SetChannelSamplingTime(adc, LL_ADC_SetChannelSamplingTime(adc,
__LL_ADC_DECIMAL_NB_TO_CHANNEL(current_channel), __LL_ADC_DECIMAL_NB_TO_CHANNEL(current_channel),
LL_ADC_SAMPLINGTIME_92CYCLES_5 LL_ADC_SAMPLINGTIME_12CYCLES_5
); );
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* @date 2022 * @date 2022
* *
* @author Clément Foucher <clement.foucher@laas.fr> * @author Clément Foucher <clement.foucher@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/ */
...@@ -209,6 +210,10 @@ void HardwareConfiguration::setLeg2Off() ...@@ -209,6 +210,10 @@ void HardwareConfiguration::setLeg2Off()
hrtim_stop_leg2(); hrtim_stop_leg2();
} }
void HardwareConfiguration::setHrtimAdcTrigInterleaved(uint16_t new_trig)
{
set_adc_trig_interleaved(new_trig);
}
///// /////
// Extra UART // Extra UART
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* @date 2022 * @date 2022
* *
* @author Clément Foucher <clement.foucher@laas.fr> * @author Clément Foucher <clement.foucher@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/ */
...@@ -97,6 +98,8 @@ public: ...@@ -97,6 +98,8 @@ public:
static void setLeg1Off(); static void setLeg1Off();
static void setLeg2Off(); static void setLeg2Off();
static void setHrtimAdcTrigInterleaved(uint16_t new_trig);
// Extra UART // Extra UART
static void extraUartInit(); static void extraUartInit();
static char extraUartReadChar(); static char extraUartReadChar();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* @date 2022 * @date 2022
* *
* @author Clément Foucher <clement.foucher@laas.fr> * @author Clément Foucher <clement.foucher@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/ */
...@@ -46,8 +47,11 @@ void _initialize() ...@@ -46,8 +47,11 @@ void _initialize()
// Perform default configration // Perform default configration
configure_adc_trigger_source(1, hrtim_ev1); configure_adc_trigger_source(1, hrtim_ev1);
configure_adc_trigger_source(2, hrtim_ev1); configure_adc_trigger_source(2, hrtim_ev3);
configure_adc_trigger_source(3, software); configure_adc_trigger_source(3, software);
adc_configure_discontinuous_mode(1, 1);
adc_configure_discontinuous_mode(2, 1);
} }
} }
...@@ -131,15 +135,15 @@ void configure_adc_default_all_measurements() ...@@ -131,15 +135,15 @@ void configure_adc_default_all_measurements()
const char* adc1_channels[] = const char* adc1_channels[] =
{ {
"I1_LOW",
"V1_LOW", "V1_LOW",
"V2_LOW",
"V_HIGH" "V_HIGH"
}; };
const char* adc2_channels[] = const char* adc2_channels[] =
{ {
"I1_LOW",
"I2_LOW", "I2_LOW",
"V2_LOW",
"I_HIGH" "I_HIGH"
}; };
......
...@@ -127,6 +127,8 @@ void hrtim_interleaved_pwm_update(float32_t pwm_duty_cycle) ...@@ -127,6 +127,8 @@ void hrtim_interleaved_pwm_update(float32_t pwm_duty_cycle)
leg_set(TIMA, pwm_pulse_width, 0); leg_set(TIMA, pwm_pulse_width, 0);
leg_set(TIMB, pwm_pulse_width, pwm_phase_shift); leg_set(TIMB, pwm_pulse_width, pwm_phase_shift);
} }
hrtim_update_adc_trig_interleaved( (pwm_pulse_width>>1) + (pwm_pulse_width>>2));
} }
/** /**
...@@ -281,3 +283,8 @@ void hrtim_start_leg2() ...@@ -281,3 +283,8 @@ void hrtim_start_leg2()
{ {
leg_start(TIMB); leg_start(TIMB);
} }
void set_adc_trig_interleaved(uint16_t new_trig)
{
hrtim_update_adc_trig_interleaved(new_trig);
}
...@@ -117,6 +117,12 @@ void hrtim_start_leg1(); ...@@ -117,6 +117,12 @@ void hrtim_start_leg1();
*/ */
void hrtim_start_leg2(); void hrtim_start_leg2();
/**
* @brief Updates the adc trigger moment
*
* @param[in] new_trig defines the triggering moment
*/
void set_adc_trig_interleaved(uint16_t new_trig);
#endif // HRTIM_CONFIGURATION_H_ #endif // HRTIM_CONFIGURATION_H_
...@@ -83,6 +83,7 @@ void hrtim_init_voltage_buck(); ...@@ -83,6 +83,7 @@ void hrtim_init_voltage_buck();
void hrtim_init_voltage_boost(); void hrtim_init_voltage_boost();
void hrtim_init_voltage_leg1_buck_leg2_boost(); void hrtim_init_voltage_leg1_buck_leg2_boost();
void hrtim_init_voltage_leg1_boost_leg2_buck(); void hrtim_init_voltage_leg1_boost_leg2_buck();
void hrtim_update_adc_trig_interleaved(uint16_t new_trig);
......
...@@ -33,11 +33,18 @@ ...@@ -33,11 +33,18 @@
void _hrtim_init_events() void _hrtim_init_events()
{ {
hrtim_adc_trigger_set_postscaler(0, 9);
hrtim_adc_trigger_en(1, 1, LL_HRTIM_ADCTRIG_SRC13_TIMACMP3); hrtim_adc_trigger_en(1, 1, LL_HRTIM_ADCTRIG_SRC13_TIMACMP3);
hrtim_cmp_set(0, TIMA, CMP3xR, 1); hrtim_adc_trigger_en(3, 2, LL_HRTIM_ADCTRIG_SRC13_TIMBCMP4);
hrtim_update_adc_trig_interleaved(1);
} }
void hrtim_update_adc_trig_interleaved(uint16_t new_trig)
{
hrtim_cmp_set(0, TIMA, CMP3xR, new_trig);
hrtim_cmp_set(0, TIMB, CMP4xR, new_trig);
}
void hrtim_init_current() void hrtim_init_current()
{ {
hrtim_cm_init(); hrtim_cm_init();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment