Hi Rich.
I think I found the/one problem. I tried using the code below to debug my program, and it turns out the for some reason, the device is not writing anything the the QSPI RAM. Could you check it out yourself and let me know if this is the case? When I try reading what is in the transmit RAM, I get zero everytime even though other values were supposed to be written to it.
Here's the code:
/* * main implementation: use this sample to create your own application * */#include "support_common.h" /* include peripheral declarations and more */#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT) /* Standard IO is only possible if Console or UART support is enabled. */#include <stdio.h>#endif#define RAMlength 4#include <assert.h>int main(void){int16 i = 0;uint16 qmr;uint16 qdr;uint16 qar;uint16 qwr;uint16 tx[RAMlength];uint16 Xdata;uint16 Zdata;MCF_GPIO_DDRAN = 0xff; // set PORTAN as output portMCF_GPIO_PORTAN = 0x00; // set all values to zero (activate CS)MCF_GPIO_PQSPAR = 0x0015; // set PORTQS to primary function/* set peripheral access control register to allow read/write access to QPSI module */MCF_SCM_PACR4 = 0 | 0x04;// set QMRMCF_QSPI_QMR = 0 | MCF_QSPI_QMR_MSTR //set master mode | MCF_QSPI_QMR_BITS(0x08) //8-bit data transfer | MCF_QSPI_QMR_CPHA | MCF_QSPI_QMR_BAUD(0x10); // _CLK = 2.5MHzqmr = MCF_QSPI_QMR;printf("QMR = %d\n", qmr);// set QDLYR MCF_QSPI_QDLYR = 0; // default delays // set QIRMCF_QSPI_QIR = 0xd00f;// set Command RAMprintf("Setting Command RAM\n");MCF_QSPI_QAR = MCF_QSPI_QAR_CMD;for(i=0; i<RAMlength; i++){ qar = MCF_QSPI_QAR; printf("Current QAR = %d\n", qar); MCF_QSPI_QDR = 0; //qdr = MCF_QSPI_QDR; //printf("Current QDR = %d\n", qdr);}// set Command RAMprintf("Reading Command RAM\n");MCF_QSPI_QAR = MCF_QSPI_QAR_CMD;for(i=0; i<RAMlength; i++){ qar = MCF_QSPI_QAR; printf("Current QAR = %d\n", qar); qdr = MCF_QSPI_QDR; printf("Current QDR = %d\n", qdr);}// set Transmit RAMprintf("Setting Transmit RAM\n");tx[0] = 0x80 | (0x16<<1); //write $16tx[1] = 0x05; //set to 4 wire modetx[2] = 0 | (0x06<<1); //read $06tx[3] = 0 | (0x08<<1); //read $08MCF_QSPI_QAR = MCF_QSPI_QAR_TRANS;for(i=0; i<RAMlength; i++){ qar = MCF_QSPI_QAR; printf("Current QAR = %d\n", qar); MCF_QSPI_QDR = tx[i]; //qdr = MCF_QSPI_QDR; //printf("Current QDR = %d\n", qdr);}// read Transmit RAMprintf("Reading Transmit RAM\n");MCF_QSPI_QAR = MCF_QSPI_QAR_TRANS;for(i=0; i<RAMlength; i++){ qar = MCF_QSPI_QAR; printf("Current QAR = %d\n", qar); qdr = MCF_QSPI_QDR; printf("Current QDR = %d\n", qdr);}// set QWRMCF_QSPI_QWR = 0 | MCF_QSPI_QWR_NEWQP(0) //start execution at 0 | MCF_QSPI_QWR_ENDQP(0x3); //end at point 3qwr = MCF_QSPI_QWR;printf("QWR = %d\n", qwr);MCF_GPIO_PORTAN = 0x02;// initiate transferMCF_QSPI_QDLYR = MCF_QSPI_QDLYR_SPE;// wait for transfers to completeassert(! (MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF));while (! (MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF)) { }MCF_QSPI_QIR = MCF_QSPI_QIR_SPIF;assert((MCF_QSPI_QWR & 0xf0) >> 4 == RAMlength-1);assert(! (MCF_QSPI_QDLYR & MCF_QSPI_QDLYR_SPE)); // read dataprintf("Receiving Data\n");MCF_QSPI_QAR = MCF_QSPI_QAR_RECV;qar = MCF_QSPI_QAR;printf("Current QAR = %d\n", qar);Xdata = MCF_QSPI_QDR;//MCF_QSPI_QAR = MCF_QSPI_QAR_RECV+1;qar = MCF_QSPI_QAR;printf("Current QAR = %d\n", qar);Zdata = MCF_QSPI_QDR;printf("Ax = %d | Az = %d\n", Xdata, Zdata);MCF_GPIO_PORTAN = 0x00; }
I'll know for sure if the hardware (the QSPI ports) are working once I can be sure that it is executing the instructions.
Let me know if you run into the same problem.
Thanks,
Philip