STMicroelectronics / X-CUBE-MEMS1

X-CUBE-MEMS1 is an expansion software package for STM32Cube. The software runs on the STM32 and includes drivers that recognize the sensors and collect temperature, humidity, pressure and motion data.
https://www.st.com/en/embedded-software/x-cube-mems1.html
Other
45 stars 10 forks source link

Please add support for I3G4250D that ships with the STM32F3Discovery #11

Open bitsmaker opened 1 month ago

bitsmaker commented 1 month ago

Describe the set-up

Additional context Please add support for a BSP package for I3G4250D. Thanks

PetrSterbaST commented 1 month ago

Hello,

We don't plan to add support for this device but you can use the SW-compatible A3G4250D driver which is already supported in the package.

Thanks and regards, Petr

bitsmaker commented 1 month ago

Hi,

Thanks for the response. I did try that before posting this issue. However when I try to get the ID of the sensor it comes back as " ". I have not tried to go further despite that, thinking the BSP for the A model might be different and may not apply to the one I have.

PetrSterbaST commented 1 month ago

It should work since I2C addresses, WhoAmI and most of the registers are the same. I suggest to doublecheck your HW to determine whether you should use I2C low or high.

bitsmaker commented 1 month ago

Thank you, I will try this later in the evening.

bitsmaker commented 1 month ago

Hi Petr, I tried both I2C low and high but neither works. image

PetrSterbaST commented 1 month ago

Are you sure your communication works well? Do other sensors return their ID correctly? Maybe you could change part of your code to see where exactly it fails, like this:

if (A3G4250D_RegisterBusIO(&a3g4250d_obj_0, &io_ctx) != A3G4250D_OK) { Error_Handler(); } else if (A3G4250D_ReadID(&a3g4250d_obj_0, &id) != A3G4250D_OK) { Error_Handler(); } else if (id != A3G4250D_ID) { Error_Handler(); } else { / Successfully continue your initialization here / }

cparata commented 1 month ago

Hi @bitsmaker , checking on STM32F3Discovery schematics here, it seems to me that the I3G4250D component is connected to the MCU via SPI interface. Could you try to assign:

SPI1_CLK->PA5 SPI1_MISO->PA6 SPI1_MOSI->PA7 ChipSelect->PE3

Then, please put the initial value of the ChipSelect high. You could try to set the SPI1 as Mode0 (Polarity High, Phase 1Edge) and a frequency less than 10 MHz. Let me know if it works with this setup. Best Regards, Carlo

bitsmaker commented 1 month ago

Thanks for your suggestions but I ran into an issue. I switched the gyro to use the SPI bus. I was not sure how to set the the ChipSelect to high.

However, when initializing it it requires the ReadReg and WriteReg pointers below and the BSP function signatures do not match.

So I did this

int32_t BSP_SPI1_WriteReg(uint16_t Addr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
    return BSP_SPI1_Send(pData, Length);
}

int32_t BSP_SPI1_ReadReg(uint16_t Addr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
    return BSP_SPI1_Recv(pData, Length);
}

and then tried to use it like this but I get an ID value that does not match A3G4250D_ID

  A3G4250D_IO_t io_ctx;
  uint8_t id;
  A3G4250D_AxesRaw_t axes;

  /* Link I2C functions to the A3G4250D_GYRO driver */
  io_ctx.BusType     = A3G4250D_SPI_3WIRES_BUS;
  io_ctx.Address     = A3G4250D_I2C_ADD_H;
  io_ctx.Init        = BSP_SPI1_Init;
  io_ctx.DeInit      = BSP_SPI1_DeInit;
  io_ctx.ReadReg     = BSP_SPI1_ReadReg;
  io_ctx.WriteReg    = BSP_SPI1_WriteReg;
  io_ctx.GetTick     = BSP_GetTick;
  if (A3G4250D_RegisterBusIO(&gyroSensor, &io_ctx) != A3G4250D_OK) {
      Error_Handler();
  }

  /* Read the A3G4250D_GYRO WHO_AM_I register */
  if (A3G4250D_ReadID(&gyroSensor, &id) != A3G4250D_OK) {
      Error_Handler();
  }
  if (id != A3G4250D_ID) {
    Error_Handler();
  }

image

bitsmaker commented 1 month ago

Are you sure your communication works well? Do other sensors return their ID correctly? Yes, the accelerometer works perfectly on the I2C bus.

Is it possible to get the source for the demo code that comes pre-loaded on the STM32F3Discovery?

cparata commented 1 month ago

Hi @bitsmaker , could you try to create a new STM32CubeIDE project starting from an existing .ioc file and use as IoC file the following one:

#MicroXplorer Configuration settings - do not modify
CAD.formats=
CAD.pinconfig=
CAD.provider=
File.Version=6
I2C1.IPParameters=Timing-I2C
I2C1.Timing-I2C=0x2000090E
KeepUserPlacement=false
Mcu.CPN=STM32F303VCT6
Mcu.Family=STM32F3
Mcu.IP0=I2C1
Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=SPI1
Mcu.IP4=SYS
Mcu.IP5=USART1
Mcu.IP6=USB
Mcu.IPNb=7
Mcu.Name=STM32F303V(B-C)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PE2
Mcu.Pin1=PE3
Mcu.Pin10=PA6
Mcu.Pin11=PA7
Mcu.Pin12=PC4
Mcu.Pin13=PC5
Mcu.Pin14=PE8
Mcu.Pin15=PE9
Mcu.Pin16=PE10
Mcu.Pin17=PE11
Mcu.Pin18=PE12
Mcu.Pin19=PE13
Mcu.Pin2=PE4
Mcu.Pin20=PE14
Mcu.Pin21=PE15
Mcu.Pin22=PA11
Mcu.Pin23=PA12
Mcu.Pin24=PA13
Mcu.Pin25=PA14
Mcu.Pin26=PB3
Mcu.Pin27=PB6
Mcu.Pin28=PB7
Mcu.Pin29=PE1
Mcu.Pin3=PE5
Mcu.Pin30=VP_SYS_VS_Systick
Mcu.Pin31=VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoPartJjGyr_1.3.1_10.0.0
Mcu.Pin32=VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoSupportJjCustom_10.0.0_10.0.0
Mcu.Pin33=VP_STMicroelectronics.X-CUBE-MEMS1_VS_DeviceJjMEMS1IiApplications_10.0.0_10.0.0
Mcu.Pin4=PC14-OSC32_IN
Mcu.Pin5=PC15-OSC32_OUT
Mcu.Pin6=PF0-OSC_IN
Mcu.Pin7=PF1-OSC_OUT
Mcu.Pin8=PA0
Mcu.Pin9=PA5
Mcu.PinsNb=34
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-MEMS1.10.0.0
Mcu.ThirdPartyNb=1
Mcu.UserConstants=
Mcu.UserName=STM32F303VCTx
MxCube.Version=6.11.0
MxDb.Version=DB.6.0.110
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
PA0.Locked=true
PA0.Signal=GPXTI0
PA11.GPIOParameters=GPIO_Label
PA11.GPIO_Label=DM
PA11.Locked=true
PA11.Mode=Device
PA11.Signal=USB_DM
PA12.GPIOParameters=GPIO_Label
PA12.GPIO_Label=DP
PA12.Locked=true
PA12.Mode=Device
PA12.Signal=USB_DP
PA13.GPIOParameters=GPIO_Label
PA13.GPIO_Label=SWDIO
PA13.Locked=true
PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO
PA14.GPIOParameters=GPIO_Label
PA14.GPIO_Label=SWCLK
PA14.Locked=true
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=SPI1_SCK [L3GD20_SCL/SPC]
PA5.Locked=true
PA5.Mode=Full_Duplex_Master
PA5.Signal=SPI1_SCK
PA6.GPIOParameters=GPIO_Label
PA6.GPIO_Label=SPI1_MISO [L3GD20_SA0/SDO]
PA6.Locked=true
PA6.Mode=Full_Duplex_Master
PA6.Signal=SPI1_MISO
PA7.GPIOParameters=GPIO_Label
PA7.GPIO_Label=SPI1_MISO [L3GD20_SDA/SDI/SDO]
PA7.Locked=true
PA7.Mode=Full_Duplex_Master
PA7.Signal=SPI1_MOSI
PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=SWO
PB3.Locked=true
PB3.Signal=SYS_JTDO-TRACESWO
PB6.GPIOParameters=GPIO_Label,GPIO_Pu
PB6.GPIO_Label=I2C1_SCL [LSM303DLHC_SCL]
PB6.GPIO_Pu=GPIO_PULLUP
PB6.Locked=true
PB6.Mode=I2C
PB6.Signal=I2C1_SCL
PB7.GPIOParameters=GPIO_Label,GPIO_Pu
PB7.GPIO_Label=I2C1_SDA [LSM303DLHC_SDA]
PB7.GPIO_Pu=GPIO_PULLUP
PB7.Locked=true
PB7.Mode=I2C
PB7.Signal=I2C1_SDA
PC14-OSC32_IN.GPIOParameters=GPIO_Label
PC14-OSC32_IN.GPIO_Label=OSC32_IN
PC14-OSC32_IN.Locked=true
PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.GPIOParameters=GPIO_Label
PC15-OSC32_OUT.GPIO_Label=OSC32_OUT
PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
PC4.Locked=true
PC4.Mode=Asynchronous
PC4.Signal=USART1_TX
PC5.Locked=true
PC5.Mode=Asynchronous
PC5.Signal=USART1_RX
PE1.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PE1.GPIO_Label=MEMS_INT2 [L3GD20_DRDY/INT2]
PE1.GPIO_ModeDefaultEXTI=GPIO_MODE_EVT_RISING
PE1.Locked=true
PE1.Signal=GPXTI1
PE10.GPIOParameters=GPIO_Label
PE10.GPIO_Label=LD5 [Orange Led]
PE10.Locked=true
PE10.Signal=GPIO_Output
PE11.GPIOParameters=GPIO_Label
PE11.GPIO_Label=LD7 [Green Led]
PE11.Locked=true
PE11.Signal=GPIO_Output
PE12.GPIOParameters=GPIO_Label
PE12.GPIO_Label=LD9 [Blue Led]
PE12.Locked=true
PE12.Signal=GPIO_Output
PE13.GPIOParameters=GPIO_Label
PE13.GPIO_Label=LD10 [Red Led]
PE13.Locked=true
PE13.Signal=GPIO_Output
PE14.GPIOParameters=GPIO_Label
PE14.GPIO_Label=LD8 [Orange Led]
PE14.Locked=true
PE14.Signal=GPIO_Output
PE15.GPIOParameters=GPIO_Label
PE15.GPIO_Label=LD6 [Green Led]
PE15.Locked=true
PE15.Signal=GPIO_Output
PE2.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PE2.GPIO_Label=DRDY [LSM303DLHC_DRDY]
PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_EVT_RISING
PE2.Locked=true
PE2.Signal=GPXTI2
PE3.GPIOParameters=PinState,GPIO_Label
PE3.GPIO_Label=CS_I2C/SPI [L3GD20_CS_I2C/SPI]
PE3.Locked=true
PE3.PinState=GPIO_PIN_SET
PE3.Signal=GPIO_Output
PE4.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PE4.GPIO_Label=MEMS_INT3 [LSM303DLHC_INT1]
PE4.GPIO_ModeDefaultEXTI=GPIO_MODE_EVT_RISING
PE4.Locked=true
PE4.Signal=GPXTI4
PE5.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PE5.GPIO_Label=MEMS_INT4 [LSM303DLHC_INT2]
PE5.GPIO_ModeDefaultEXTI=GPIO_MODE_EVT_RISING
PE5.Locked=true
PE5.Signal=GPXTI5
PE8.GPIOParameters=GPIO_Label
PE8.GPIO_Label=LD4 [Blue Led]
PE8.Locked=true
PE8.Signal=GPIO_Output
PE9.GPIOParameters=GPIO_Label
PE9.GPIO_Label=LD3 [Red Led]
PE9.Locked=true
PE9.Signal=GPIO_Output
PF0-OSC_IN.GPIOParameters=GPIO_Label
PF0-OSC_IN.GPIO_Label=OSC_IN
PF0-OSC_IN.Locked=true
PF0-OSC_IN.Mode=HSE-External-Clock-Source
PF0-OSC_IN.Signal=RCC_OSC_IN
PF1-OSC_OUT.GPIOParameters=GPIO_Label
PF1-OSC_OUT.GPIO_Label=OSC_OUT
PF1-OSC_OUT.Locked=true
PF1-OSC_OUT.Signal=RCC_OSC_OUT
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F303VCTx
ProjectManager.FirmwarePackage=STM32Cube FW_F3 V1.11.4
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=0
ProjectManager.MainLocation=Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=Test_F3Disco.ioc
ProjectManager.ProjectName=Test_F3Disco
ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=EWARM V8.32
ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_I2C1_Init-I2C1-false-HAL-true,4-MX_USB_PCD_Init-USB-false-HAL-true,5-MX_MEMS_Init-STMicroelectronics.X-CUBE-MEMS1.10.0.0-false-HAL-false,6-MX_MEMS_Process-STMicroelectronics.X-CUBE-MEMS1.10.0.0-false-HAL-false
RCC.ADC12outputFreq_Value=48000000
RCC.ADC34outputFreq_Value=48000000
RCC.AHBFreq_Value=48000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2
RCC.APB1Freq_Value=24000000
RCC.APB1TimFreq_Value=48000000
RCC.APB2Freq_Value=48000000
RCC.APB2TimFreq_Value=48000000
RCC.CortexFreq_Value=48000000
RCC.FCLKCortexFreq_Value=48000000
RCC.FamilyName=M
RCC.HCLKFreq_Value=48000000
RCC.HSEPLLFreq_Value=8000000
RCC.HSE_VALUE=8000000
RCC.HSIPLLFreq_Value=4000000
RCC.HSI_VALUE=8000000
RCC.I2C1Freq_Value=8000000
RCC.I2C2Freq_Value=8000000
RCC.I2SClocksFreq_Value=48000000
RCC.IPParameters=ADC12outputFreq_Value,ADC34outputFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSEPLLFreq_Value,HSE_VALUE,HSIPLLFreq_Value,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSourceVirtual,TIM1Freq_Value,TIM2Freq_Value,TIM8Freq_Value,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOOutput2Freq_Value
RCC.LSE_VALUE=32768
RCC.LSI_VALUE=40000
RCC.MCOFreq_Value=48000000
RCC.PLLCLKFreq_Value=48000000
RCC.PLLMCOFreq_Value=24000000
RCC.PLLMUL=RCC_PLL_MUL6
RCC.RTCFreq_Value=40000
RCC.RTCHSEDivFreq_Value=250000
RCC.SYSCLKFreq_VALUE=48000000
RCC.SYSCLKSourceVirtual=RCC_SYSCLKSOURCE_PLLCLK
RCC.TIM1Freq_Value=48000000
RCC.TIM2Freq_Value=48000000
RCC.TIM8Freq_Value=48000000
RCC.UART4Freq_Value=24000000
RCC.UART5Freq_Value=24000000
RCC.USART1Freq_Value=48000000
RCC.USART2Freq_Value=24000000
RCC.USART3Freq_Value=24000000
RCC.USBFreq_Value=48000000
RCC.VCOOutput2Freq_Value=8000000
SH.GPXTI0.0=GPIO_EXTI0
SH.GPXTI0.ConfNb=1
SH.GPXTI1.0=GPIO_EXTI1
SH.GPXTI1.ConfNb=1
SH.GPXTI2.0=GPIO_EXTI2
SH.GPXTI2.ConfNb=1
SH.GPXTI4.0=GPIO_EXTI4
SH.GPXTI4.ConfNb=1
SH.GPXTI5.0=GPIO_EXTI5
SH.GPXTI5.ConfNb=1
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
SPI1.BaudRatePrescaler-Full_Duplex_Master=SPI_BAUDRATEPRESCALER_2
SPI1.CalculateBaudRate=3.0 MBits/s
SPI1.CalculateBaudRate-Full_Duplex_Master=24.0 MBits/s
SPI1.DataSize=SPI_DATASIZE_8BIT
SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=CalculateBaudRate,BaudRatePrescaler,CalculateBaudRate-Full_Duplex_Master,BaudRatePrescaler-Full_Duplex_Master,Mode-Full_Duplex_Master,Mode,VirtualType,Direction,DataSize
SPI1.Mode=SPI_MODE_MASTER
SPI1.Mode-Full_Duplex_Master=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER
STMicroelectronics.X-CUBE-MEMS1.10.0.0.BSP.number=5
STMicroelectronics.X-CUBE-MEMS1.10.0.0.BoardOoPartJjGyrJjA3G4250D=SPI
STMicroelectronics.X-CUBE-MEMS1.10.0.0.BoardOoPartJjGyr_Checked=true
STMicroelectronics.X-CUBE-MEMS1.10.0.0.BoardOoSupportJjCustomJjMOTIONIiSENSOR=true
STMicroelectronics.X-CUBE-MEMS1.10.0.0.BoardOoSupportJjCustom_Checked=true
STMicroelectronics.X-CUBE-MEMS1.10.0.0.DeviceJjMEMS1IiApplications_Checked=true
STMicroelectronics.X-CUBE-MEMS1.10.0.0.IPParameters=BoardOoSupportJjCustomJjMOTIONIiSENSOR,BoardOoPartJjGyrJjA3G4250D,MEMS1IiApplicationsCcDeviceJjApplication
STMicroelectronics.X-CUBE-MEMS1.10.0.0.MEMS1IiApplicationsCcDeviceJjApplication=DataLogTerminal
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.STBoard=false
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.api=BSP_BUS_DRIVER
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.component=
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.condition=SEMBoardOoPartJjGyrJjA3G4250DJjSPI
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.instance=SPI1
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.ip=SPI
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.mode=Full-Duplex Master
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.name=A3G4250D BUS IO driver
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.semaphore=
STMicroelectronics.X-CUBE-MEMS1.10.0.00.BSP.solution=SPI1
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.STBoard=false
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.api=BSP_COMMON_DRIVER
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.component=
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.condition=\!(SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiIntensityDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiIntensityDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiIntensityDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiGyroscopeCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiGyroscopeCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiGyroscopeCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiGyroscopeCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiAccelerometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiAccelerometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiAccelerometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiAccelerometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiMagnetometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiMagnetometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiMagnetometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiMagnetometerCalibration | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiTiltSensing | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiTiltSensing | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiTiltSensing | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiTiltSensing | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiVerticalContext | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiVerticalContext | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiVerticalContext | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiCarryPosition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiCarryPosition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiCarryPosition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiECompass | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiECompass | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiECompass | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiECompass | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiGestureRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiGestureRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiGestureRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiDynamicInclinometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiDynamicInclinometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS02A1IiDynamicInclinometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiDynamicInclinometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiAirplaneDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiAirplaneDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiAirplaneDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiActiveTime | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiActiveTime | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiActiveTime | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiActivityRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiActivityRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiActivityRecognition | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiActivityRecognitionWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiActivityRecognitionWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiActivityRecognitionWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiFallDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiFallDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiFallDetection | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiFitnessActivities | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiFitnessActivities | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiFitnessActivities | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiPedometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiPedometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiPedometer | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiPedometerWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiPedometerWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiPedometerWrist | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiPoseEstimation | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiPoseEstimation | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiPoseEstimation | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS01A3IiStandingSittingDesk | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjIKS4A1IiStandingSittingDesk | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjCUSTOMIiStandingSittingDesk | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjAccelCalibration2IiIIS2ICLX | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjTiltSensing2IiIIS2ICLX | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjPresenceDetectionIiSTHS34PF80 | SEMMEMS1IiApplicationsCcDeviceJjApplicationJjAirQualityIiSGP40)
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.instance=PA0
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.ip=GPIO
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.mode=EXTI
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.name=BSP BUTTON
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.semaphore=
STMicroelectronics.X-CUBE-MEMS1.10.0.01.BSP.solution=PA0
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.STBoard=false
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.api=BSP_COMMON_DRIVER
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.component=
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.condition=
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.instance=USART1
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.ip=UART|USART|LPUART
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.mode=Asynchronous
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.name=BSP USART
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.semaphore=
STMicroelectronics.X-CUBE-MEMS1.10.0.02.BSP.solution=USART1
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.STBoard=false
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.api=Unknown
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.component=
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.condition=SEMBoardOoPartJjGyrJjA3G4250DJjSPI
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.instance=PE3
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.ip=GPIO
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.mode=Output
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.name=A3G4250D_CS
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.semaphore=
STMicroelectronics.X-CUBE-MEMS1.10.0.03.BSP.solution=PE3
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.STBoard=false
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.api=BSP_COMMON_DRIVER
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.component=
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.condition=
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.instance=PE11
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.ip=GPIO
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.mode=Output
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.name=BSP LED
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.semaphore=
STMicroelectronics.X-CUBE-MEMS1.10.0.04.BSP.solution=PE11
STMicroelectronics.X-CUBE-MEMS1.10.0.0_SwParameter=BoardOoSupportJjCustomJjMOTIONIiSENSOR\:true;BoardOoPartJjGyrJjA3G4250D\:SPI;MEMS1IiApplicationsCcDeviceJjApplication\:DataLogTerminal;
USART1.BaudRate=115200
USART1.IPParameters=VirtualMode-Asynchronous,BaudRate
USART1.VirtualMode-Asynchronous=VM_ASYNC
VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoPartJjGyr_1.3.1_10.0.0.Mode=BoardOoPartJjGyr
VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoPartJjGyr_1.3.1_10.0.0.Signal=STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoPartJjGyr_1.3.1_10.0.0
VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoSupportJjCustom_10.0.0_10.0.0.Mode=BoardOoSupportJjCustom
VP_STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoSupportJjCustom_10.0.0_10.0.0.Signal=STMicroelectronics.X-CUBE-MEMS1_VS_BoardOoSupportJjCustom_10.0.0_10.0.0
VP_STMicroelectronics.X-CUBE-MEMS1_VS_DeviceJjMEMS1IiApplications_10.0.0_10.0.0.Mode=DeviceJjMEMS1IiApplications
VP_STMicroelectronics.X-CUBE-MEMS1_VS_DeviceJjMEMS1IiApplications_10.0.0_10.0.0.Signal=STMicroelectronics.X-CUBE-MEMS1_VS_DeviceJjMEMS1IiApplications_10.0.0_10.0.0
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=STM32F3DISCOVERY
boardIOC=true

please rename the .ioc file as "Test_F3Disco.ioc". Then, you just need to compile the code as it is without any settings in the Pinout; the settings inside the IoC file should be already fine for your hardware setup. I was able to compile the code with STM32CubeIDE but I do not have the Discovery board to see if the generated binary is also functional. Let me know if this code works on your side. Best Regards, Carlo

bitsmaker commented 1 month ago

I get this error and the STM32CubeIDE keeps looping image

cparata commented 1 month ago

Did you install X-CUBE-MEMS1 pack version 10.0.0? Which version of STM32CubeIDE are you using?

cparata commented 1 month ago

To install the X-CUBE-MEMS1 pack version 10.0.0, you must select "Software Packs" -> "Manage Software Packs" -> "STMicroelectronics" tab -> Expand "X-CUBE-MEMS1" -> Install the version 10.0.0

bitsmaker commented 1 month ago

Its already installed image

cparata commented 1 month ago

Have you tried to do what the popup suggested? I would click on Project -> Generate Code to complete the code generation. Another option could be to install STM32CubeMX v6.11.0, open the IoC file with STM32CubeMX and generate the code for STM32CubeIDE. In this way, you should be able to open and compile the firmware with STM32CubeIDE. Best Regards, Carlo

bitsmaker commented 1 month ago

Yes, i did generate it using Cube MX 6.11.1. When I tried to load it to the STM32CubeIDE I get image

bitsmaker commented 1 month ago

I do not think it is generating the project file correctly

bitsmaker commented 1 month ago

I used a combination of files in this and this directories to call BSP_GYRO_Init and this time the correct ID is returned for I3G4250D gyro. I have not made it to actually getting the data, will try that tomorrow.

cparata commented 1 month ago

Test_F3Disco.zip Hello @bitsmaker , I uploaded the entire project. I compiled it with STM32CubeIDE on my side without any issue. Could you try it? Best Regards, Carlo

cparata commented 1 month ago

To import it in STM32CubeIDE you just need to open the IDE and then "Import projects"->"General"->"Existing Projects into Workspace" and then point to the "STM32CubeIDE" folder that you can find in the zip file that I attached above.

bitsmaker commented 1 month ago

Hi, I am not going to be near my home computer go a couple of days so will try this out when I get back. Thanks for all your help

bitsmaker commented 1 month ago

I used your zip project and it does work correctly, thanks for that. I tried to use your custom read/write functions in my project and they do not work. Here is my project zipped. Can you help me understand what I am doing wrong?

gyrotest2.zip

cparata commented 1 month ago

Hello @bitsmaker , that's really strange. I controlled again the pins and they seem fine on my side. Did you try to debug the code that I sent to you? Where is it stuck? Best Regards, Carlo

bitsmaker commented 1 month ago

It does not seem to get the right who am I Id. That's where its stuck

bitsmaker commented 1 month ago

It would be easier if you were to make a screen recording of a brand new project that shows from scratch how to setup the hardware.

cparata commented 1 month ago

Hello @bitsmaker , could you provide the revision of your STM32F3Discovery board? I think that I understood your issue. Best Regards, Carlo

cparata commented 1 month ago

I think that the reason is that you have a revision of the board that mounts the L3GD20 instead of the I3G4250D. The ID of the L3GD20 in fact is 0xD4, instead the ID of the I3G4250D is 0xD3. If, starting from the code that I provided, you try to change the check on the ID (where the code is stuck) in order to go on (so replace the ID label with 0xD4), then the firmware should continue without any issue. Unfortunately in the X-CUBE-MEMS1 we do not support the L3GD20 that is obsolete and not recommended for new designs. So, I cannot be sure that the driver of the A3G4250D is 100% compatible with the L3GD20, but you can try if at least it works for your use case. Best Regards, Carlo

bitsmaker commented 1 month ago

image

bitsmaker commented 1 month ago

I should be clear, when I said this "It does not seem to get the right who am I Id. That's where its stuck", I meant that your project does find the right ID, it comes back as 0xD3. But when I tried to create a project from scratch identical to yours it did not work correctly. Hence, I was asking for a screen capture so I can see what you are doing to setup the project

cparata commented 1 month ago

Hello @bitsmaker , so you should have the board with effectively the I3G4250D. If you get as ID 0xD3, it means that my code should work properly. Did you try to open an hyperterminal with baudrate 115200 to see if my code works fine? You should see as output the values of the gyroscope. You can start your project from the .ioc that you can find in the zip file that I shared. There you can see all the settings that I did. Best Regards, Carlo

cparata commented 2 weeks ago

Hello @bitsmaker , any update on this issue? Could we close it? Best Regards, Carlo