Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


switch case statement within SPI interface

Hello Everyone,

I am using stm32f405VGTx mcu for my project. I connected an another MCU (as master) which talks with my stm32f405 mcu over SPI. With my 405 I have connected the external ADC(PCM 1808) and accelerometer over I2S and SPI respectively. Now I want to write a routine in my slave 405 mcu - like a switch case statement on spi so that when the master MCU gives command whether to get ADC value or accelerometer value or FFT value from my 405 mcu. But I am very confused how can I incorporate case statement in SPI routine.

Does anyone code before in this situation, a basic help will be appreciated.

Thank you.

Given that the slave only exchanges values with the master when the master says so, the process is along the lines of:
- wait until the master sends the command (this might require sending back a “no value” value such as 0 or 0xff or something that the protocol you define says “ignore this value”)
- read the command value that the master has sent you - you can then use ‘if’ or ‘switch’ statements depending on how many commands there are
- get the appropriate value and load it into the SPI buffer
- wait again until the master does another exchange
- throw away the received value or interpret it as the next command (whatever the protocol you have devices says)
- repeat the above
Of course you need to do all of this before the master requests the 2nd exchange. If this is not possible, then you can either use additional GPIO lines to let the master know when the data is ready or load up the SPI buffer with the “ignore this value” value so that the master knows that the slave has not yet completed and that it will keep trying until it does get a valid value.
This is all part of the protocol you need to define.
Susan


 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs