Skip to content

Stm32 sensor fix #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2021
Merged

Conversation

runger1101001
Copy link
Member

Fix for issue #82

This pull request modifies MagneticSensorSPI.cpp in the following ways:

  1. Remove #ifndef STM32 masking out spi.beginTransaction and spi.endTransaction on STM32 MCUs. I can find no reason for doing this, and on the other hand doing so means the SPI settings don't get applied for the SPI call, meaning firstly that SPI clock speeds were all wrong for all STM32 users, and some users had clock speeds faster than the sensors they were using supported. Additionally there would be big problems using multiple SPI devices on the bus.

  2. Remove the setClockDivider call - is there any architecture that needs it? Its an obsolete way of setting the SPI clock speed, the modern way is to use SPISettings and beginTransaction(). @askuric do you know where this came from?

  3. Change the 10us delay, between calls, replacing it with a 1us delay. The sensors I can find (AMS, MagAlpha) all require significantly <1us downtime between requests, so this should be sufficient. For ESP32 there is a 50us delay (!) - anyone know why? I've left this for the moment.

@runger1101001
Copy link
Member Author

I think this can be merged into dev branch, so it gets some wider testing...
It changes only one file, and can be easily backed out if it causes problems. It's working for me.

@runger1101001 runger1101001 merged commit a13a76e into simplefoc:dev May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant