Page 1 of 1

MOD5213 QSPI PROBLEM

Posted: Mon Jan 30, 2012 12:29 pm
by nicobari
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.

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
}
where ZACCL_OUT etc.. are the commands sent by MOD5213 to the IMU. The sub-routine for reading data from IMU is as follows

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);
	}
}
and my main code is as follows

Code: Select all

sim.spi.qdlyr = (0x03FF | 0x8000);
while (1) {
		OSTimeDly(TICKS_PER_SECOND / 5);
		Read_IMU_SPI();
}
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.

Re: MOD5213 QSPI PROBLEM

Posted: Mon Jan 30, 2012 5:03 pm
by lgitlitz
I have used QSPI in this fashion for high speed A/D reading. Usually the way this works is by first sending a 16-bit command to the sensor. After the sensor has this command it knows which data to send back. The next 16-bit transfer will contain the data returned from the previous command on the RX line. So you keep sending the 16-bit command data but the data you are receiving is from the previous command you sent. This looks exactly like what you are seeing except the data you get in imu_raw[0] should be the TEMP_OUT return data. The first cycle you run the QSPI imu_raw[0] will be junk data but is should be TEMP_OUT the second time it is processed.

-Larry Gitlitz

Re: MOD5213 QSPI PROBLEM

Posted: Mon Jan 30, 2012 8:34 pm
by nicobari
thnx for replying, I also though about it but also thought it to be trivial. Your reply will make me look into that more seriously this time. Thanks again.