Where to start STM32H7 support

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Wed Jan 20, 2021 9:26 am

Giovanni wrote:Hi,

As far I know TIMs are exactly the same on all platforms. Are you changing PWM channels settings on the fly?

Giovanni


Yeah so the process is:

1. setup PWM and output pulses using DMAR on the UP channel
2. output the pulses
3. switch the PWM timer to do input capture using one of the CH channels but sharing the same DMA channel as (1) so use dmaSetRequestSource()
4. once input capture is complete reset dmaSetRequestSource and reset PWM for output through pwmStop()/pwmStart()

So I have tested this on an F745 board with identical pinout and it works fine, so something is going on on H7

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Where to start STM32H7 support

Postby Giovanni » Wed Jan 20, 2021 10:16 am

Changing the timer settings while the timer is active does not look very clean, it is possible they added some logic to prevent this kind of things (for safety).

Giovanni

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Wed Jan 20, 2021 11:04 am

Giovanni wrote:Changing the timer settings while the timer is active does not look very clean, it is possible they added some logic to prevent this kind of things (for safety).

Giovanni


Ok so maybe I should disable the timer before any settings change each time? What would be the best way of doing this cleanly?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Where to start STM32H7 support

Postby Giovanni » Wed Jan 20, 2021 12:06 pm

You should do all settings before starting the timer, the PWM driver does not allow this because the start function writes all registers then starts it (CEN bit).

You may try to toggle CEN to zero then do your setup and see if this solves your problem but the driver has not been designed for this.

Giovanni

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Wed Jan 20, 2021 2:31 pm

Giovanni wrote:You should do all settings before starting the timer, the PWM driver does not allow this because the start function writes all registers then starts it (CEN bit).

You may try to toggle CEN to zero then do your setup and see if this solves your problem but the driver has not been designed for this.

Giovanni


Ok that's ok - when I do the input capture I am essentially ignoring the pwm setup (pwm is done), I do the input capture then restart the pwm driver.

What I am thinking is perhaps I should call pwmStop before this second part - is that safe/efficient in an ISR context?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Where to start STM32H7 support

Postby Giovanni » Wed Jan 20, 2021 3:05 pm

It is not possible, stop() and start() functions cannot be used from ISR and stop() would also stop clocks, you could not write registers anymore.

Giovanni

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Wed Jan 20, 2021 3:40 pm

Giovanni wrote:It is not possible, stop() and start() functions cannot be used from ISR and stop() would also stop clocks, you could not write registers anymore.

Giovanni


Ok thanks - I'll try with CEN for now. I notice that we are setting it to 0 but only after manipulating CCER/CCMR1/CCMR2

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Wed Jan 20, 2021 10:58 pm

andypiper wrote:
Giovanni wrote:It is not possible, stop() and start() functions cannot be used from ISR and stop() would also stop clocks, you could not write registers anymore.

Giovanni


Ok thanks - I'll try with CEN for now. I notice that we are setting it to 0 but only after manipulating CCER/CCMR1/CCMR2


Makes no difference and I am out of ideas, will have to park this for now :(

andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Where to start STM32H7 support

Postby andypiper » Fri Jan 22, 2021 9:26 am

On a related note are there any examples of setting up MPU attributes on memory regions? It looks like STM recommend using non-cacheable memory for DMA, so I am going to try that but struggling to find an example of doing this the ChibiOS way

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Where to start STM32H7 support

Postby Giovanni » Fri Jan 22, 2021 9:54 am

Hi,

No need to struggle too much, in mcuconf.h there is this:

Code: Select all

/*
 * Memory attributes settings.
 */
#define STM32_NOCACHE_MPU_REGION            MPU_REGION_6
#define STM32_NOCACHE_SRAM1_SRAM2           FALSE
#define STM32_NOCACHE_SRAM3                 TRUE


The related code is in hal_lld.c, you can use that as example.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 30 guests