cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed number (5) of Pulses triggered by external event. (STM32H753ZI to ADS8556)

psh25
Associate II

I'm using an STM32H753ZI, specifically the Nucleo H753ZI board, to read data from an ADS8556 adc. Upon signaling to the ADS8556 to start a conversion, a BUSY signal on the adc goes high and falls when the data is ready to be read.

I currently have BUSY connected to PG13, set up as HRTIM1 AF2, with falling edge sensitivity and configured as External Event 10. I have nRD set up on PG6, HRTIM1 CHE1, with its SetSource configured to HRTIM_OUTPUTSET_EEV_10, and its ResetSource as HRTIM_OUTPUTRESET_TIMCMP1, in line with the desired pulse width. For CHE, I also have `ResetTrigger = HRTIM_TIMRESETTRIGGER_UPDATE | HRTIM_TIMRESETTRIGGER_EEV_10`, continuous mode (I've also tried SINGLESHOT_RETRIGGERABLE), and repetition counter = 4.

With this setup, I'm seeing nRD (PG6) pulse once on the falling edge of BUSY, and not the desired 5 (I'm only reading from 5 channels out of 6 on the ADS8556). I've played around with a number of HRTIM configurations, but this is the best I've managed so far. It appears RepetitionCounter is not doing anything, maybe I'm misunderstanding completely.

Am I even on the right track? To distill down my goal, I want to be able to generate 5 active-low pulses on a pin, triggered by the falling edge of an external signal. Another future consideration is I will also need the pin for these 5 pulses to trigger DMA transfers.

Thanks in advanced!

psh25_0-1742552150198.png

psh25_1-1742558795396.png

 

 

6 REPLIES 6

Hello, 

The main purpose of repetition counter is handling interrupt and update rate:

RM0433: "The main purpose of the repetition counter is to adjust the period interrupt rate and off-load the CPU by decoupling the switching frequency and the interrupt frequency."

This won't help to generate a specific number of pulses. For this you may need to involve a FW action that disables the counter and outputs at the right moment (pulse low for instance). 

 

Best regards.

What about this section in AN4776? "N-pulse waveform generation using one-pulse mode"

Hello, 

The AN4776 and the section is about General purpose timers: GPTIM, and not high-resolution timer: HRTIM, which has a different architecture, and far different features than GPTIM.

Best regards.

The approach I'm trying now is to set the RepetitionCounter of HRTIM E (nRD) to 4 (5pulses) and setting up the preload register to disable HRTIM E output 1 on the repetition update.

Right now I have the following for HRTIM E:

pTimerCfg.PreloadEnable = HRTIM_PRELOAD_ENABLED;
pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED;
pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;
pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_EEV_10;

On every falling edge of CONVST (HRTIM B), I have a `HRTIM1_TIMB_IRQHandler` that sets the following in the preload register

hhrtim.Instance->sCommonRegs.ODISR |= HRTIM_ODISR_TE1ODIS;

However, this seems to shut down HRTIM E completely, and I get no pulses, as if there's a premature update event.
Am I using the preload register correctly? and is this approach on the right track?

Hello, 

It seems that code generated by CubeMx was modified, I don't see for instance this configuration: HAL_HRTIM_WaveformTimerControl initialy generated by CubeMx.

I guess that "convst start" command is the one intended to start the burst of pulses, 

The reasoning of using the update on repetition is correct, however the initial configuration may be wrong since customized, do you confirm it is working even outside the scope of repetition?

You will need also to force the update at the end of configuration (done by HAL of CubeMx if generated correctly), otherwise the configuration doesn't become active. When the update is done on the roll-over/reset, this happens at the end of first period, here you will need enough EEV_10 to trigger the update after 5 repetitions.

Best regards.

Hi Yassine,

The code generated from CubeMx never included HAL_HRTIM_WaveformTimerControl, in my case, nor do I see HAL_HRTIM_WaveformTimerControl anywhere in stm32h7xx_hal_hrtim.h

What CubeMx configurations is HAL_HRTIM_WaveformTimerControl downstream of? Do I need this for my purposes?

For things like 

pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED;
pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_EEV_10;
pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;
pTimerCfg.PreloadEnable = HRTIM_PRELOAD_ENABLED;
I'm calling `HAL_HRTIM_WaveformTimerConfig(&hhrtim, HRTIM_TIMERINDEX_TIMER_E, &pTimerCfg)` to set these configurations. Does this not make these configurations immediately active?

Yes, the "convst start" command kicks off the read sequence I want. It starts the CONVST (HRTIM B) pulses. On the rising edge of CONVST, the external ADC starts the conversion and pulls the BUSY signal high. When the conversion completes, the ADC pulls BUSY low, which triggers EEV10 and starts HRTIM E (nRD). I have EEV10 configured as the ResetTrigger for HRTIM E, which is in continuous mode.
I have an interrupt configured to fire on 
HRTIM_TIM_IT_CMP2 of HRTIM B (CONVST). I've also tried configuring 
pTimerCfg.InterruptRequests of HRTIM B as HRTIM_TIM_IT_SET1 and HRTIM_TIM_IT_RST1.
In 
HRTIM1_TIMB_IRQHandler, I intend to set up the preload register to disable HRTIM E, which in theory should only get loaded into the active register after the repetition counter on HRTIM E finishes, thus producing only 5 pulses. However, when I have `hhrtim.Instance->sCommonRegs.ODISR |= HRTIM_ODISR_TE1ODIS;` in HRTIM1_TIMB_IRQHandler, the pulses never even fire on nRD (HRTIM E).
 
I've attached a screenshot of my scope, when I don't have `hhrtim.Instance->sCommonRegs.ODISR |= HRTIM_ODISR_TE1ODIS;` in HRTIM1_TIMB_IRQHandler. I circled in red where I've tried having the interrupt configured to fire.
psh25_0-1743493188942.png

Is `hhrtim.Instance->sCommonRegs` the preload register? Is there another update event that I have accidentally configured that's causing this to be loaded into the active register prematurely? and not 

HRTIM_UPDATEONREPETITION_ENABLED?