i have a small problem, i try to fix it, and can't find a solution.
I want to use a PWM-Interrupt to start the ADC-conversion. After the conversion is finished i want to start the adc_handler to get the values.
I get an pwm-interrupt in the pwm-handler but the adc_handler is not triggered.
From the code you provided, it looks like you have set up the ADC and PWM interrupts correctly. However, you are not starting the ADC conversion in the PWM interrupt handler.
In the PWM_Handler function, you should add a line of code to start the ADC conversion. This can be done by setting the START bit in the ADC_CR register.
Here's an example of how you could modify the PWM_Handler function:
sorry my mistake.
That way you describe is working for that i have to deactivate the hardware-trigger and write the pwm_handler like you posted. but i dont want to use the pwm handler i want to start the adc-conversion directly with the pwm-eventline mechanism.
I see, if you want to start the ADC conversion directly with the PWM event line mechanism, you can use the following approach:
Configure the PWM timer to generate an event when the pulse starts. You can do this by setting the PWM timer's event generation register (EGR) to trigger on the update event, like this:
rustCopy code
TIM1->EGR |= TIM_EGR_UG; // Generate an update event to start the PWM timer
TIM1->CR2 |= TIM_CR2_MMS_1; // Set the PWM timer to generate an update event on the TRGO line when a new PWM period starts
Configure the ADC to start a conversion when it receives a trigger from the PWM timer's event line. You can do this by setting the ADC's external trigger conversion mode (EXTEN) to trigger on the rising edge of the PWM timer's event line, like this:
lessCopy code
ADC1->CR2 |= ADC_CR2_EXTEN_0; // Set the ADC to trigger on a rising edge
ADC1->CR2 |= ADC_CR2_EXTSEL_0 | ADC_CR2_EXTSEL_2; // Set the ADC trigger source to the TRGO line of TIM1
Start the PWM timer, which will trigger the ADC to start a conversion at the beginning of each PWM period.
lessCopy code
TIM1->CR1 |= TIM_CR1_CEN; // Start the PWM timer
I hope this helps! Let me know if you have any further questions.
thanks for your support. but i don't understand what you want to do with the TIM1.
It looks more complicated than i read in the datasheet of the controller.
normally i just want to fire an eventline interrupt using the the pwm register.
what i read in the datasheet is that the eventline is called when the comparator is working. And the comparator is just working with the sync channels.
so what i try i to snyc my channels in the pwm and configure the comparator.
the code