0
\$\begingroup\$

I am using stm32l452 and toshiba 4Gbit flash ic, and I am trying to write and read data from flash via quadspi. I achieved reading flash and manufacturar id from flash(with commands, not with using data register) but I am unable to write anything on data register. I am monitoring it on system viewer window while trying to write something on register and it just gets nothing. Stays at 0x00000000 all the time. Does anyone have any idea about what is wrong?

I am sharing the code part where I programmed qspi.

uint32_t QSPI_init(void)
{  
uint32_t dummy=0;   
uint32_t rx=0;  

SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); //QSPI clock signal

QUADSPI->CR &= ~(QUADSPI_CR_EN);    //  qspi disable

RCC->AHB3RSTR |= RCC_AHB3RSTR_QSPIRST; //force reset

RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_QSPIRST); //force release   

QUADSPI->CR |= (QUADSPI_CR_EN);   //  qspi enable

dummy = QUADSPI->DR;    

QUADSPI->FCR |= 0x1F;   //flag clear register

QUADSPI->CR |= 0x01000310; // FCLK = FAHB/2 // 1/2 cycle shift // 4 BYTE TRESHOLD

QUADSPI->DCR |= 0x00000101; // CSHT ve CKMODE // nCS stays high for at least 2 cycles between Flash memory commands // CLK must stay high while nCS is high

QUADSPI->DCR |= (0x1C << 16); // memory size    

QUADSPI->DLR |= 0x02; // 4 bytes are to be transferred

QUADSPI->CCR |= 0b00000001000000000000000110011111; //read-id   // WRITE MODE

//while(QUADSPI->SR & 0x20); /* Wait for busy flag to be cleared */

QUADSPI->DR |= 0xA0A0A0A0;  // DATA TO SEND

while(QUADSPI->SR & 0x20); /* Wait for busy flag to be cleared */

dummy = QUADSPI->DR;  //READ REGISTER
rx = QUADSPI->DR;

return rx;

}   
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Not entirely sure for quad SPI, but some other ST peripherals cannot be configured while they are enabled. So it could be that QUADSPI->CR |= (QUADSPI_CR_EN); should happen after all the other configuration stuff. Also using a debugger to watch registers might cause issues as the reading might change the state of the peripherals state machine making your code not working as expected. The data to send should just use DR = and not DR |= , the latter is a read modify write and you just want to write or you loose something from the RX buffer. \$\endgroup\$
    – Arsenal
    Jan 16, 2020 at 14:42
  • \$\begingroup\$ Thank you for advices, but they didn't solve the problem. I can't still write data on _dr register. \$\endgroup\$ Jan 17, 2020 at 6:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.