[SOLVED] How can I trigger ADC with an external clock generator on STM32 board?

Status
Not open for further replies.

nadd

Member level 1
Joined
Oct 3, 2022
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
322
Hello,

I'm trying to trigger ADC on the STM32F303RE Nucleo board with an external clock generator. Without external trigger settings, it works. I changed the trigger source to Timer8, then in TIM8 settings, I chose External Clock Source. What am I doing wrong? I didn't change any user codes, should I add pin up/down commands to start ADC in user code sections?

My ADC(DMA) and TIM8 settings:
(My clock(square wave) generator connected to PB6 pin)


 

Hi,

Why via timer?
Can't you use EXTI line?

I've no experience with the STM32F4xx ... just used STM32F1xx devices.

Klaus
 

Hi,

Why via timer?
Can't you use EXTI line?

I've no experience with the STM32F4xx ... just used STM32F1xx devices.

Klaus
Hi Klaus,

In ADC's external trigger source settings, there are only timers. No other option. Because of that, I chose one of them, then I tried to use it with an external source.
 

Hi,

please show the whole CubeMX window.
..with all ADC setups.

currently we can't even see which ADC you did choose.

Klaus
 

Hi,

Do you need help?

Klaus
Hi,

Yes, I need help.


I save the data to a size of 12000 buffer, then write in serial port. Without external trigger settings, it works. But, when I change "Continous Conversion Mode-Disable, External Trigger Source-Timer8", it doesn't work.


Also, briefly the user codes I use(some of the variables are for saving to an SD card):

C:
#define ADC_BUF_LEN 12000
 
void myprintf(const char *fmt, ...) {
  static char buffer[ADC_BUF_LEN];
  va_list args;
  va_start(args, fmt);
  vsnprintf(buffer, sizeof(buffer), fmt, args);
  va_end(args);
 
  int len = strlen(buffer);
  HAL_UART_Transmit(&huart2, (uint64_t*)buffer, len, -1);
 
}
 
HAL_ADC_Start_DMA(&hadc1, (uint16_t*)adc_buf, ADC_BUF_LEN);
 
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
    for (int i = 0; i < ADC_BUF_LEN; ) {
    myprintf("%i\r\n", adc_buf[i]);
    i++;
    }
 

Hi,


Then please scroll down the MODE window and show the screenshot.

Klaus
I'm so sorry, I didn't realize before that Mode window's name and there are other options there. EXTI is here, I see now. It is on "Disable"
 

HI,

Set it on "Regular conversion trigger". Then see the extra pin coming up on the CHIP view.

With this external pin (EXTI) you should be able to start a single conversion or even a conversion sequence.
I never used/tried this, though.

Klaus
 
Reactions: nadd

    nadd

    Points: 2
    Helpful Answer Positive Rating
HI,

Set it on "Regular conversion trigger". Then see the extra pin coming up on the CHIP view.

With this external pin (EXTI) you should be able to start a single conversion or even a conversion sequence.
I never used/tried this, though.

Klaus
Hi Klaus,

Thank you so much! It works now! I've been trying all the Timer settings for a week to do this. I wish I could see EXTI earlier.

Thanks again
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…