2024-09-09 12:58 AM - edited 2024-09-09 05:34 AM
Please help pointing to learning material on this.
We can unserstnd that below library was written in proper engineering style so that it can be (a) ported to various STM chips. (b) can select use of POLL, Interrupt and DMA mode by "linking/select" the needed "function definition"
1. New to these and we worked for some time and still did not got to understand HOW (a) and (b) is performed in practice. If skipping the 'proper' way (tons of Macro, define and ifdef), we can read the sensor with two HAL calls. But we need to learn the proper way :)
2. Also, needing to get it right in "project" to link and work together with others code for inside and outside of the STM MCU. Our project is created using RAW STM chip WITHOUT the Board Support Package, like Nucleo. So, we need to deffine the hardware ourself (and still did not got it right)
3. We are loss in multiple 'INIT' functions that 'need to be called in corect sequence". Some SOFTWARE setup data structure, i2c HANDLE, some HARDWARE setup for STM32 chip clock chain/interrupt controller/dma controller, some setup the I2C controller inside the STM MCU.
Now, we stuck at NOT having a data structure IO being initialized with selection of POLL/Interrupt/DMA function prototype. Others is ok so far.
* typedef struct
{
VEML6030_Init_Func Init;
VEML6030_DeInit_Func DeInit;
uint16_t ReadAddress;
uint16_t WriteAddress;
VEML6030_IsReady_Func IsReady;
VEML6030_WriteReg_Func WriteReg;
VEML6030_ReadReg_Func ReadReg;
VEML6030_GetTick_Func GetTick;
} VEML6030_IO_t;
https://github.com/STMicroelectronics/stm32-veml6030
It says, "Please refer to the repository of the BSP board driver you are using to know which version of this BSP component driver to use. It is crucial that you use a consistent set of versions as indicated."
Many thanks for advises. Now is our time to learn these once and for all and burden is ours! These MCU are complex to use. Good news is this is near the last one to overcome and light at end of tunnel. :)
Solved! Go to Solution.
2024-09-11 09:35 AM
Hello @David_,
STM32 HAL User Manual and STM32 LL User Manual provide detailed information on how to use the HAL and LL libraries.
Additionally, here are some corrected and verified links for articles on STM32 I2C and using DMA with STM32:
Also, STM32CubeFW has several examples demonstrating the use of POLL, Interrupt, and DMA modes:
STM32CubeF4: You can find various example projects in the Projects directory. For instance, the STM32F410xx-Nucleo board has several examples demonstrating the use of POLL, Interrupt, and DMA modes:
STM32CubeU5: BSP example for the B-U585I-IOT02A uses the VEML3235 ambient light sensor, which shares similar functionalities with the VEML6030. By following this example, you can easily adapt the code for the VEML6030 with minor adjustments.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-09-09 01:51 PM - edited 2024-09-09 01:52 PM
Hi,
It is your project/product and you are free to decide what is the proper way or style.
Professional help is available here - in writing code, software setup, consulting, board design and more.
2024-09-11 09:35 AM
Hello @David_,
STM32 HAL User Manual and STM32 LL User Manual provide detailed information on how to use the HAL and LL libraries.
Additionally, here are some corrected and verified links for articles on STM32 I2C and using DMA with STM32:
Also, STM32CubeFW has several examples demonstrating the use of POLL, Interrupt, and DMA modes:
STM32CubeF4: You can find various example projects in the Projects directory. For instance, the STM32F410xx-Nucleo board has several examples demonstrating the use of POLL, Interrupt, and DMA modes:
STM32CubeU5: BSP example for the B-U585I-IOT02A uses the VEML3235 ambient light sensor, which shares similar functionalities with the VEML6030. By following this example, you can easily adapt the code for the VEML6030 with minor adjustments.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-09-11 04:20 PM
Many thanks for reply. We shall be reading the doc.
1. Can we run the two board demo you mentioned, we have one NucleoF401RE and several Nucleo F103RB?
2. In MX, ST SPI CPOL and CPHA (1_EDGE, 2_EDGE), how it corresponds to different terminology used by some sensor datasheet, mode 1 to mode 4, or mode "00", "11"
3. For SPI and I2C GPIO pin, how to select maximum output speed for a given SPI/I2C clock rate (i2C 100kHz, SPI 3 to 8MHz)? Does it set drive current to control slew rate to minimize generated RFI interference? Will setting to excessive "very high" produce ringing in signal?
What is 'fast mode' tick box on some but not all GPIO pin?
Many thanks
2024-09-12 10:07 AM
Hello @David_,
(1) You can run the two-board I2C communication demo using the Nucleo-F401RE and Nucleo-F103RB boards. However, you will need to make some adjustments.
(2) and (3) STM32 Reference Manual : provides detailed documentation on SPI and I2C modes:
Fast mode is not linked to GPIO, but to I2C. The fast mode is the frequence range from 100Khz to 400Khz.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-09-12 10:28 AM - edited 2024-09-12 10:28 AM
Hi @Dor_RH ,
> Understand the CPOL and CPHA values to configure the correct SPI mode.
I believe @David_ does understand what CPOL and CPHA do. I believe he refers to the fact, that in CubeMX/Cube ST uses a non-standard terminology (1_EDGE, 2_EDGE) to describe the CPHA settings, with no explanation what's their relationship.
Yes, this can be found out by studying the Cube sources (macros which define 1_EDGE and 2_EDGE, I'm not going to look them up now), but once ST made the wrong decision to depart from the industry standard, this should be remedied by an explicit explanation in CubeMX at least.
VEML6030 has an I2C interface. Why do you want to set up SPI?
JW
2024-09-13 04:06 AM
Hello,
In MX, you can find a parameter description regarding clock phase (CPHA) that may help you.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-09-13 04:22 AM
Thanks, this explains it.
A little bit clumsy, but at least the values are there.
Many many years ago, when I first came across SPI, that material put it in this way: CPHA=0 -- sample, then shift; CPHA=1 -- shift, then sample. I find this to be a concise description up to this day. This of course was in the times when familiarity with hardware (here shift registers, as SPI is nothing but) was a given amongst mcu programmers.
JW