I’m learning how to use MagAlpha MA730. I can read the angle correctly.
But when I want to read the register, I get the angle value twice, not the register value.
Then what’s the reason?
I’m using Atmel ASF4. The MCU is ATSAMD21. Here is the code snippet.
/* read register*/
uint8_t txData1[2];
uint8_t rxData1[2];
uint8_t txData2[2];
uint8_t rxData2[2];
uint8_t address=0x01;
txData1[0]=(0x2<<5)|(0x1F&address);
txData1[1]=0x00;
txData2[0]=0x00;
txData2[1]=0x00;
//First frame
gpio_set_pin_level(CS,false);
spi_packet.rxbuf=rxData1;
spi_packet.txbuf=txData1;
spi_packet.size=2;
result=spi_m_sync_transfer(&SPI_0,&spi_packet);
gpio_set_pin_level(CS,true);
delay_ms(2);
//Second frame
gpio_set_pin_level(CS,false);
spi_packet.rxbuf=rxData2;
spi_packet.txbuf=txData2;
spi_packet.size=2;
result=spi_m_sync_transfer(&SPI_0,&spi_packet);
gpio_set_pin_level(CS,true);
Values in rxData1 and rxData2 are all angle values.