MOD5213 QSPI PROBLEM
Posted: Mon Jan 30, 2012 12:29 pm
Hi, I am trying to read data from an IMU using MOD5213 QSPI. The procedure to get data using QSPI from IMU is to send command to IMU and then read data sent from IMU corresponding to the command. (for example if MOD5213 sends the command 0x0A00 the IMU transmits acceleration data along X-axis and so on). I have to read 3 acceleration, 3 angular rates, 3 magnetic heading data and 1 temp data (so in total 10 data). I configured my QSPI in the following way.
where ZACCL_OUT etc.. are the commands sent by MOD5213 to the IMU. The sub-routine for reading data from IMU is as follows
and my main code is as follows
the problem is when I am printing the data received I am getting a random value in imu_raw[0], imu_raw[1] is giving me ZACCL data, imu_raw[2] is giving XACCL data i.e my data output is getting shifted by one place in the array. Am I doing anything wrong? By the way IMU sends data in 14 bits.
Code: Select all
void Init_IMU_SPI() {
sim.spi.qmr = 0xC380;//baudrate 258000 Hz, CPOL=1, CPHA=1,Master Mode
//Command Ram
sim.spi.qar=0x20;//first Command RAM entry
//QSPI configuration in Command RAM
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qdr=0x7D00;
sim.spi.qar = 0x0000; //select the first transmit ram entry
//Data to be sent to ADIS IMU
sim.spi.qdr = ZACCL_OUT;
sim.spi.qdr = XACCL_OUT;
sim.spi.qdr = YACCL_OUT;
sim.spi.qdr = ZGYRO_OUT;
sim.spi.qdr = XGYRO_OUT;
sim.spi.qdr = YGYRO_OUT;
sim.spi.qdr = ZMAGN_OUT;
sim.spi.qdr = XMAGN_OUT;
sim.spi.qdr = YMAGN_OUT;
sim.spi.qdr = TEMP_OUT;
sim.spi.qwr=0x5900;//wrap around mode enabled, return to 0x00 after executing 10 commands.
sim.spi.qir=0xD00F;//enable write collison, abort bus errors and clear any interrupts.
sim.spi.qdlyr=0x03FF;//user defined delays
}
Code: Select all
void Read_IMU_SPI() {
unsigned int flag;
flag=sim.spi.qir;
if((flag & 0x0001)==0x0001){
sim.spi.qar = 0x0010; //select the first receiver entry
int i = 0;
for (i = 0; i < 10; i++) {
imu_raw[i] = (unsigned int) (sim.spi.qdr);
}
}
Code: Select all
sim.spi.qdlyr = (0x03FF | 0x8000);
while (1) {
OSTimeDly(TICKS_PER_SECOND / 5);
Read_IMU_SPI();
}