There must be a simple code for this circuit - sine in sine out. Any solution welcome.

ted:

I just reread every one of your posts since you joined the forum. The questions you are asking indicate a lack of understanding of digital and analog processing using microprocessors. We (forum) can fill in only so many holes in your knowledge but in my opinion you need to take a step back and do some Internet study before you ask questions.

For example, in this current thread, you wish to take an analog input and output an analog waveform; unfortunately you have chosen a uC that does not have a DAC. Therefore, PWM (digital signal) must be used with an integration capacitor to convert varying pulse width to a varying (analog) Voltage.

The Arduino.cc forum is geared to new users of the Arduino paradigm. .. this STM32duino forum was implemented by users with significant experience and there is very little material here to point a beginner. We do try and point all users to solutions, but (the forum) biggest job is working with users that are having complex behavior issues where the STM32DUINO "core" appears to be malfunctioning and in using the STM32Fxxxx internal modules for peripheral connections. Few of us here with experience have sufficient time to assist a member with the full scope of learning. I expect to see the Op post code that compiles and performs some function to represent an issue. I do not expect an Op to ask for (complete) design and coding assistance.

The OP is looking for a different stuff - most probably (it is not "PWM basic") he wants to process an audio signal.
ADC->DSP->DAC(via PWM).
To process a speech (300-3000Hz) for example, he wants a loop with say 8kHz tick, and during this 125us he wants do provide 12bit ADC, process the signal (ie FIR filter) and pass the result to PWM output (set to 1/32kHz pwm period for example).
Doable with BluePill, it requires some experience, however (or a ready to get code).
I would suggest to OP to start with something easier to master at this stage..

<...>
To process a speech (300-3000Hz) for example, he wants a loop with say 8kHz tick, and during this 125us he wants do provide 12bit ADC, process the signal (ie FIR filter) and pass the result to PWM output (set to 1/32kHz pwm period for example).
<...>

In his first post, the Op shows a 7kHz sinewave input ... definitely not what I would have taken as speech input processing (which I fully agree could be done on a generic blue pill.) Part of the problem is that only the Op knows what he is thinking and clearly communicating that to the forum in a query is imperative if any of us are going to be able to assist in earnest.

English is not my native language, what is meant Op?
I have no problem with DAC , LC filter for PWM is working very good. Internet study are not answer my questions, there is a lot of info but when you are looking for answer for your questions is hard to find it.
For example the filters, always for low frequencies and output always on serial plotter , I have never seen an example for traditional analog ecvivalent: " Filter input on pin - Filter - Filter output on pin".

you do not understand the loop () implementation in Arduino - sometimes I am confused what is belongs to it , I know analog world, digital = sirst steps.

ADC->DSP->DAC(via PWM). = exactly that, for single frequency

I think dannyf's response was just for fun. = I thought the same, but I tried.