Hello,
I have tryied to make the wire as short as possible, the board with the memory flash is directly connect to the coldfire.
I have tryied the exemple of code of JimDon.
I have tryied three differents flash memory (I have tried the one you talk about Kremer the M25P40).
But nothing works I already have the same problem when I send the write enable command and then I read the status register I have 0.
Is there something to do before using a flash memory ?
Have you an idea about what can I forget to do ?
Here is the code I use please tell me if you see somethings wrong or if you can test it ?
After QSPI_init(), I call qspi_write_enable() and then I call qspi_read_register and I have 0 everytime.
Thanks for your help
Fabien
Code:
void QSPI_init(){ //initialisation des pins QSPI MCF_GPIO_PQSPAR |= MCF_GPIO_PQSPAR_QSPI_DOUT_DOUT | MCF_GPIO_PQSPAR_QSPI_DIN_DIN | MCF_GPIO_PQSPAR_QSPI_CLK_CLK | MCF_GPIO_PQSPAR_QSPI_CS0_CS0 | MCF_GPIO_PQSPAR_QSPI_CS1_CS1 | MCF_GPIO_PQSPAR_QSPI_CS2_CS2 |MCF_GPIO_PQSPAR_QSPI_CS3_CS3; //initialisation registre mode MCF_QSPI_QMR = MCF_QSPI_QMR_BAUD(0x4B);// MCF_QSPI_QMR |= MCF_QSPI_QMR_DOHIE;// MCF_QSPI_QMR |= MCF_QSPI_QMR_CPOL;// MCF_QSPI_QMR |= MCF_QSPI_QMR_CPHA; MCF_QSPI_QMR |= MCF_QSPI_QMR_MSTR; MCF_QSPI_QMR |= MCF_QSPI_QMR_BITS(8); //initialisation des délais// MCF_QSPI_QDLYR = MCF_QSPI_QDLYR_DTL(2); MCF_QSPI_QDLYR = (0| MCF_QSPI_QDLYR_QCD(0x4B)|// delay from assertion of CS to valid QSPI_CLK transition MCF_QSPI_QDLYR_DTL(9) // delay after transfer ); //initialisation du registre de control des interruption (pas d'interruption et effacement de toutes les interruptions) MCF_QSPI_QIR = MCF_QSPI_QIR_WCEFB | MCF_QSPI_QIR_ABRTB | MCF_QSPI_QIR_ABRTL |
MCF_QSPI_QIR_SPIF | MCF_QSPI_QIR_ABRT|MCF_QSPI_QIR_WCEF/*|MCF_QSPI_QIR_SPIFE*/; }int qspi_write_enable(){ MCF_QSPI_QAR = 0x20; // set QAR to command RAM zone MCF_QSPI_QDR = 0x0E00; // last transfer MCF_QSPI_QAR = 0x00; // set QAR to transmit RAM zone MCF_QSPI_QDR = 0x06; // send READ instruction to flash MCF_QSPI_QWR = (0|MCF_QSPI_QWR_CSIV| MCF_QSPI_QWR_ENDQP( 0 ));// chip select active low // set end queue pointer, other pointers null MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE; // enable qspi module /******************* INTERRUPT HANDLING ********************/ // write collision error if( (( MCF_QSPI_QIR & MCF_QSPI_QIR_WCEF ) == MCF_QSPI_QIR_WCEF)) { return -1; } // abort error if( (( MCF_QSPI_QIR & MCF_QSPI_QIR_ABRT ) == MCF_QSPI_QIR_ABRT)) { return -2; } // wait until tranfer finished //while(ptr_sQSPI->temps_set != 1); while ( (MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF) != MCF_QSPI_QIR_SPIF ); MCF_QSPI_QIR |= MCF_QSPI_QIR_SPIF; // QSPI finished flag cleared // MCF_GPIO_PORTQS = 0x08;}int qspi_read_register(uint16 * buffer, unsigned int size){ int i = 0; MCF_QSPI_QAR = 0x20; // set QAR to command RAM zone MCF_QSPI_QDR = 0x8E00; // READ instruction time for ( i = 1 ; i < size ; i++ ) { MCF_QSPI_QDR = 0x8E00; // data receive time } MCF_QSPI_QDR = 0x0E00; // last transfer MCF_QSPI_QAR = 0x00; // set QAR to transmit RAM zone MCF_QSPI_QDR = 0x05; // send READ instruction to flash for( i = 0 ; i < size ; i++ ) { MCF_QSPI_QDR = 0x0; // requested data sent out }MCF_QSPI_QWR = (0|MCF_QSPI_QWR_CSIV| MCF_QSPI_QWR_ENDQP( size));// chip select active low // set end queue pointer, other pointers null // MCF_GPIO_PORTQS = 0x00; MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE; // enable qspi module /******************* INTERRUPT HANDLING ********************/ // write collision error if( (( MCF_QSPI_QIR & MCF_QSPI_QIR_WCEF ) == MCF_QSPI_QIR_WCEF)) { return -1; } // abort error if( (( MCF_QSPI_QIR & MCF_QSPI_QIR_ABRT ) == MCF_QSPI_QIR_ABRT)) { return -2; } // wait until tranfer finished //while(ptr_sQSPI->temps_set != 1); while ( (MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF) != MCF_QSPI_QIR_SPIF ); MCF_QSPI_QIR |= MCF_QSPI_QIR_SPIF; // QSPI finished flag cleared MCF_QSPI_QAR = 0x10 + 1; // set QAR to receive RAM zone for ( i = 0; i < size; i++ ) { // get from hi-byte in the basic address of Receive RAM zone *buffer = MCF_QSPI_QDR ; buffer++; } return 0;}
Message Edited by fjoli on
2008-07-08 04:32 PM