2020-01-06 07:35 AM
Hello,
I am simply tring to communicate with the L3GD20 Gyrosensor using the WhoAmI command.
I am sending 0x0F and i'm expecting 0xD7 back (11010111) but I only received 0xFF which means i'm doing something wrong
I am using STM32CubeMX to generate the code , Keil IDE and using STM32L071
https://www.mouser.co.uk/datasheet/2/389/l3gd20h-954865.pdf
Any help would be appreciated!
//put CS low
HAL_GPIO_WritePin(GYRO_CS_GPIO_Port,GYRO_CS_Pin,GPIO_PIN_RESET);
//Transmit register address
spiData[0] = 0x0F;
HAL_SPI_Transmit(&hspi1,spiData,1,10);
//read
HAL_SPI_Receive(&hspi1,&spiData[1],1,10);
//put CS High
HAL_GPIO_WritePin(GYRO_CS_GPIO_Port,GYRO_CS_Pin,GPIO_PIN_SET);
Solved! Go to Solution.
2020-01-07 12:45 AM
I realised my error, I didn't enable the read bit. so instead of sending 0x0F (0000 1111) I should have sent 0xCF (1100 1111).
2020-01-07 12:45 AM
I realised my error, I didn't enable the read bit. so instead of sending 0x0F (0000 1111) I should have sent 0xCF (1100 1111).