AnsweredAssumed Answered

MCF5272 QSPI

Question asked by Rosario Tripodi on Mar 5, 2012
Latest reply on Mar 15, 2012 by Rosario Tripodi

Good morning to all,

i need your help about QSPI implementation. I'm a rockie on firmware implementation and now i must implement a QSPI to connect a single device. Now i haven't the device, and to test my code i've applied a jumper to MOSI and MISO pin.

My problem is after the first transmition, i call my QSPI_Transfer function 4 times with 4 diffferent values, after the first transmition i call QSPI_Transfer with another value, it was transmitted, but when i try to read the receive data i read the data of my first transmition.This happens for every transmition, i receive data of my previous transmittion.For example:

 

transmit data :

0x01

0x02

0x03

0x04

receive data:

0x01

0x01

0x02

0x03

 

To resolve this problem i have added a for cycle after transmition and i read the correct data.This solution can be right?
what i wrong in my code? what is the problem?

 

I've implemented this code:

 

in main:

main(){

BYTE data,Receive;

QSPI_Init();

.

.

.

 

data=0x01;

Receive=QSPI_Transfer(data);

data=0x02;

Receive=QSPI_Transfer(data);

data=0x03;

Receive=QSPI_Transfer(data);

data=0x04;

Receive=QSPI_Transfer(data);

}

 

void QSPI_Init(void){

// I call this function only 1 a time
WORD config = 41215;   
MCF5272_WR_QSPI_QMR(config);  //set the QMR register
}


//For my purpose i call this function 4 times
BYTE QSPI_Transfer(BYTE Data){

BYTE Ricezione;
BYTE i;
WORD QMR;
//Set data
MCF5272_WR_QSPI_QAR(QSPI_RAM_TX);     // QSPI_RAM_TX is 0x00
MCF5272_WR_QSPI_QDR(Data);      //data is 0x05

//Set Wrap register
MCF5272_WR_QSPI_QWR(QSPI_TX_QWR);  //set wrap to 0

//set command
MCF5272_WR_QSPI_QAR(QSPI_RAM_CMD); // QSPI_RAM_CMD is 0x20
MCF5272_WR_QSPI_QDR(QSPI_CMD);   //command is 16384

//Start transfer
MCF5272_WR_QSPI_QDLYR(QSPI_START);   //QSPI_START is 32768

while(!MCF5272_RD_QSPI_QIR){}   //Wait untill SPIF is set to 1

MCF5272_WR_QSPI_QIR(0x00);   //Reset SPIF

MCF5272_WR_QSPI_QAR(QSPI_RAM_RX);   //QSPI_RAM_RX is 0x10

for(i=0;i<200;i++){}    //wait the update of data

Ricezione=MCF5272_RD_QSPI_QDR;   //read transmetted data

return Ricezione;
}

 

Thank you for your help.

Outcomes