Skip to main content
Associate
June 14, 2026
Question

How should the FMAC of STM32G474 be configured to obtain correct calculation data?

  • June 14, 2026
  • 2 replies
  • 56 views

Hi,

I encountered problems during the development process of using FMAC. To illustrate the problem simply, I used FMAC to implement an RC filter, by which I mean to illustrate the calculation problems of FMAC.

RC filter:10K+10nF

Its discrete z-domain expression:(Ts=1e-6,Tustin)

so I get fixed-point parameters :

I referred to the example program of AN5305 and used a 1-us timer to trigger ADC sampling. After the ADC sampling is completed, DMA writes to the WriteData of FMAC, and then the ReadData is processed in the interrupt as follows:

As shown above, my current ADC sample is 0, and my Vref is set to 800. I think the output of FMAC as an RC filter should be around 800 in the DC case, but actually it is not. It is a relatively small value. Why is that?

May I ask if there is a problem with my configuration of FMAC?

 

 

2 replies

ST Technical Moderator
June 18, 2026

Hello ​@TakingLee 

About your question "May I ask if there is a problem with my configuration of FMAC?" and based on the information provided, the FMAC configuration seems to be correct.
 
A quick reminder regarding the use of variables in callbacks: they must be declared as "volatile".
Then we invite you to verify that the "Fmac_output" array is correctly declared as volatile in your application.
 
Otherwise, about your problem, we have no enough data to make a correct analysis.
Then could you give us more details about your ADC configuration ?
What sampling time is it using ?
Is the raw ADC measurement correct relative to your input signal ?
 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
TakingLeeAuthor
Associate
June 21, 2026

Hello,

Thanks for your answers.

Please refer to the attachment for relevant project codes. As shown in the figure above, the calculation result of FMAC is different from that calculated by the software. In this project, the period time of Timer6 is set to 10 μs. FMAC is calculated once and calculated by the software method once every 10 μs. This project is modified from the official ST example program.

Why are the calculation results of the FMAC module different from those of the software mode?