Electronics > Microcontrollers

32F417 SPI running at one third the speed it should

<< < (17/18) > >>

bson:

--- Quote from: nctnico on January 22, 2022, 02:39:56 pm ---
--- Quote from: Siwastaja on January 22, 2022, 08:25:31 am ---
--- Quote from: peter-h on January 22, 2022, 07:31:49 am ---
--- Code: ---SPI2->DR;
SPI2->SR;
--- End code ---

which someone here told me does a read of that register(s). Well, it does not

--- End quote ---

It definitely does, unless you have written your own header which fails to qualify SPI2 as volatile, or use a broken compiler.

--- End quote ---
This is interesting. It is the first time I ever see this mentioned. I just checked with GCC 4.6.2; the statement does perform a read but it does not result in less instructions compared to reading a value into a dummy variable (either optimised for size or speed ). That makes sense because in the end the data that is read must end up in a register even if it isn't used. I do get a warning from the IDE that it is a statement without effect though.

--- End quote ---
This was changed reasonably recently (maybe even in gcc 10).  If you have a volatile variable on the stack now the compiler guarantees it occupies space on the stack throughout its entire formal scope, and all accesses to the stack slot become barriers.

harerod:

--- Quote from: bson on February 03, 2022, 07:39:27 pm ---...This was changed reasonably recently (maybe even in gcc 10).  If you have a volatile variable on the stack now the compiler guarantees it occupies space on the stack throughout its entire formal scope, and all accesses to the stack slot become barriers.
--- End quote ---
Thanks for the heads-up.
STM32CubeIDE release v1.8.0 RN0114 states
GNU Tools for STM32, based on GNU Tools for Arm Embedded Processors 9-2020-q2-update 9.3.1 20200408 (release)
So most discussions for STM32 would be about GCC 9.x

peter-h:
Yes; current Cube, v1.8.0, comes with the above v9.x compiler. I checked it myself, compiling and checking the binary matches byte for byte. I also checked the version which is output when invoking the exe from a command line.

It's been at that version for a long time.

bson:

--- Quote from: harerod on February 04, 2022, 09:00:00 am ---
--- Quote from: bson on February 03, 2022, 07:39:27 pm ---...This was changed reasonably recently (maybe even in gcc 10).  If you have a volatile variable on the stack now the compiler guarantees it occupies space on the stack throughout its entire formal scope, and all accesses to the stack slot become barriers.
--- End quote ---
Thanks for the heads-up.
STM32CubeIDE release v1.8.0 RN0114 states
GNU Tools for STM32, based on GNU Tools for Arm Embedded Processors 9-2020-q2-update 9.3.1 20200408 (release)
So most discussions for STM32 would be about GCC 9.x

--- End quote ---
That's not necessarily true.  I don't use their IDE and I use the toolchains provided by ARM:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

keremsur:
How can one use SPI in a 16-bit mode? Do you mean actually setting SPI to 16 bits so that it is shifting out, and shifting in, a 16 bit value at a time?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version