Where to start STM32H7 support

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

Moderator: RoccoMarco

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

Post by andypiper »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to start STM32H7 support

Post by Giovanni »

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

Post by andypiper »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to start STM32H7 support

Post by Giovanni »

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

Post by andypiper »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to start STM32H7 support

Post by Giovanni »

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

Post by andypiper »

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

Post by andypiper »

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

Post by andypiper »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to start STM32H7 support

Post by Giovanni »

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
Post Reply