Simon Chamlian

QSPI problems in 5282

Discussion created by Simon Chamlian on Feb 2, 2009
Latest reply on Oct 22, 2011 by Rich Testardi
Hi,
 
Trying to program a SPI flash but it is not working, as I want to.
 
1) To check the completion of a transfer:

 When transfer is initiated (MCF_QSPI_QDLYR |=  MCF_QSPI_QDLYR_SPE; ).
 
  Is it recommended to check the SPI bit?
Code:
 while(1) {  vuint16 qdlyr=MCF_QSPI_QDLYR;  if( (qdlyr & MCF_QSPI_QDLYR_SPE >> 0xF)==0)   break; }

 
Or simply the SPIF bit: 
Code:
while (!(MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF))   ; //wait for queue to end

 
or both?
 
2)  I am always getting the response from the SPI Flash in QRR1 ( rcv[1] in code below). Any clue why?
 
Code:
void SPI_Flash_ReadStatusReg(void){ int i; spi_word_t rcv[16];  // QSPI Module  Command RAM Registers (QCR0-QCR15) #define SPI_CMD_CS_ASRT     0xC0E0 //chip select 0 Active Low   // Load Command: Set queue address (QAR) to COMMAND address [0x20 - 0x2F] MCF_QSPI_QAR = MCF_QSPI_QAR_CMD;  // Write the command words MCF_QSPI_QDR = (uint16)(SPI_CMD_CS_ASRT);   // Write Tx Data: Set queue address (QAR) to Transmit address [0x00 - 0x0F] MCF_QSPI_QAR = MCF_QSPI_QAR_TRANS;   // Load the data to transmit   MCF_QSPI_QDR = RDSR; //read status register (i,e. RDSR=0x05)  /* Determine the active level, the first and last index of the transmit queue */ MCF_QSPI_QWR = (0 | (MCF_QSPI_QWR & MCF_QSPI_QWR_CSIV)       | MCF_QSPI_QWR_NEWQP(0)       | MCF_QSPI_QWR_ENDQP(1));    /* begin transfer */ MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE;  /* When transfer queue ends, QIR[SPIF] is set */ while (!(MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF))  ; //wait for queue to end /* Set RAM address pointer to received data */ MCF_QSPI_QAR = MCF_QSPI_QAR_RECV; /* read received data from the RAM */ for (i = 0; i < 16; ++i) {  rcv[i] = MCF_QSPI_QDR; } /* done */}

 
 
Thanks,
 
Simon
 

Outcomes