cancel
Showing results for 
Search instead for 
Did you mean: 

How do I reset an SPI module and associated DMA streams, without resetting the whole microcontroller?

arnold_w
Senior
Posted on April 04, 2016 at 18:26

The original post was too long to process during our migration. Please click on the attachment to read the original post.
5 REPLIES 5
Posted on April 04, 2016 at 18:56

Honestly I don't think you could pay me enough to want to wade into this mire...

You've got software written by people who don't use the hardware, you've got hardware designed by people who've not had to implement software drivers, or a practical system using their own design. In the industry we describe this as not eating the dog food.

You can reset the peripherals at a bus/unit level. Like an asynchronous reset input of yore.

#define     __DMA1_FORCE_RESET()   (RCC->AHBRSTR |= (RCC_AHBRSTR_DMA1RST))

#define     __DMA1_RELEASE_RESET()   (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_DMA1RST))

The SPI+CRC seems like an unmitigated cluster, you have to track bytes, and change modes, and you have Rx/Tx channels that aren't bonded in any sensible way. The SPI really needs a byte/word counter. And a better thought out chip-select generator/handler.

https://en.wikipedia.org/wiki/Eating_your_own_dog_food

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Radosław
Senior
Posted on April 04, 2016 at 19:34

>>#define     __DMA1_RELEASE_RESET()   (RCC->AHBRSTR &= ~(RCC_AHBRSTR_DMA1RST))

This will reset all streams

Posted on April 04, 2016 at 20:16

Indeed, but not the entire micro-controller. So marginally less worse.

A lot of the design here has been poorly thought through.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Radosław
Senior
Posted on April 04, 2016 at 20:26

Disabling stream will be enough.

arnold_w
Senior
Posted on April 06, 2016 at 09:40

The recommendation to use __DMA1_FORCE_RESET() and __DMA1_RELEASE_RESET() pointed me in the direction to try the following:

                  __SPI2_FORCE_RESET();

                  __SPI2_RELEASE_RESET();

This seems to work fine, now my SPI-module recovers just fine after a faulty transmission. Thank you for your help.