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


STM32F1 SPI Simpleton Implementation Fail

France

Hi Ben,

First of all you should check that in your project settings at “project >> C/C++ Build >> Settings >> Tool Settings >> MCU GCC Compiler >> Warnings” the “All Warnings (-Wall)” option is checked. This will gives you warnings on potential errors you may have in your code.

Second, there is indeed several problems in your code:

  1. You do not need any parentheses in (pData) = ; you can write it simply as pData =
  2. pData, as its name implies, should be a pointer to uint8_t data (bytes);
    1. You should declare it as uint8_t *pData;
    2. Then you cannot assign it a byte, you must assign it the address of a byte, by pData = &TheDataItself;
    3. Finally you can pass to HAL_SPI_Transmit either pData or &TheDataItself, both will request HAL to transmit 1 byte of data (value of cnt), located in the TheDataItself variable
Probably the cleaner way to transmit a byte on the SPI would be to write:
uint8_t TheDataItself = 0xFF;
HAL_SPI_Transmit(&hspi2, &TheDataItself, sizeof(TheDataItself), 10); // 10 is the time out value.

Finally, I think you should read one of the numerous C programming courses you can find on the web: whatever it may look like, C is not a simple programming language, especially when going to pointers, and you need some guidance when starting to program in C.

Hope this helps clarifying things,

Bernard (Ac6)