Hi all,
I am currently having difficulty in getting the X,Y,Z of gyroscope's data output. The gyroscope I am using is L3G4200D. The Microcontroller board is Hercules RM42x LaunchPad Evaluation Kit. I attached a sample code of what I did below. From my understanding, writing 0x8f should return 0xd3. This is used to check if the SPI connection is successful. Currently it is returning 0.
Thank you all in advance for all the help.
Regards,
Yuan Fa
#include "sys_common.h"
#include "system.h"
#include "spi.h"
#include "stdio.h"
void main(void) {
spiDAT1_t dataconfig1_t;
dataconfig1_t.CS_HOLD = FALSE;
dataconfig1_t.WDEL = TRUE;
dataconfig1_t.DFSEL = SPI_FMT_0;
dataconfig1_t.CSNR = 0xFE;
uint16 TX_Data_Master[16] = { 0x8F,0x00 };
uint16 TX_Data_Master2[16] = { 0x00 };
uint16 RX_Data_Master[16] = { 0 };
_enable_IRQ();
spiInit();
spiSendData(spiREG2, &dataconfig1_t, 16, TX_Data_Master);
printf("Value at p1: %d\n", *RX_Data_Master);
spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Master2,RX_Data_Master);
printf("Value at p1: %d\n", *RX_Data_Master);
while (1);
}