cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G491RE QUADSPI ISSUE

zeboss49
Associate III

Hello,

I'm facing a strange issue with the quadspi peripheral.

I'm using it to interface with a W25q256jveiq, a quad spi enabled flash chip from Winbond.

As long as I use one line SPI or dual I/O mode all works fine.

I can access the flash chip with no issue at a 80 MHz clock speed.

As soon as I switch to a quad I/O mode I'm facing a strange issue.

A string signature is stored at address 0.

The written signature is correct, I can read it properly in dual I/O mode.

In quaq I/O modes the \r\n bytes in the string are not read properly but all other characters are.properly read.

The alternate byte is properly set (it works fine in dual I/O mode).

The dummy clock cycles are set according to the data sheet (may be I'm wrong about them, the main difference with dual I/O mode is that there's no dummy clock cycles in dual I/O mode).

The command for dual I/O mode is:

com.InstructionMode = QSPI_INSTRUCTION_1_LINE;
com.Instruction = 0xBC; // Fast Read Dual I/O with 4-Byte Address
com.AddressSize = QSPI_ADDRESS_32_BITS;
com.AddressMode = QSPI_ADDRESS_2_LINES;
com.Address = buffer_address;
com.AlternateByteMode = QSPI_ALTERNATE_BYTES_2_LINES;
com.AlternateBytes = 0xFF;
com.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
com.DummyCycles = 0;
com.DataMode = QSPI_DATA_2_LINES;
com.NbData = data_length;
com.DdrMode = QSPI_DDR_MODE_DISABLE;
com.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
com.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

The command setup for quad I/O is:

com.InstructionMode = QSPI_INSTRUCTION_1_LINE;
com.Instruction = 0xEC; // Fast Read Quad I/O with 4-Byte Address
com.AddressSize = QSPI_ADDRESS_32_BITS;
com.AddressMode = QSPI_ADDRESS_4_LINES;
com.Address = buffer_address;
com.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES;
com.AlternateBytes = 0xFF;
com.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
com.DummyCycles = 4;
com.DataMode = QSPI_DATA_4_LINES;
com.NbData = data_length;
com.DdrMode = QSPI_DDR_MODE_DISABLE;
com.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
com.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

To be sure that the issue is not related to the data length, I've inserted a \r\n pair in the middle of the string and they are also corrupted with the same data pattern as the ending \r\n.

I've tried another command, 0x6C (Fast Read Quad Output with 4-Byte Address [address is sent in 1 line mode],), same issue despite the fact that this command does not require the alternate byte but 8 dummy clock cycles instead of 4 for the 0xEC command.

Look at the differences in locations [55], [56] and [57]
Data read in QUAD I/O Mode
flash_page_bufferuint8_t [64]0x20003098 <ucHeap+6584>
flash_page_buffer[0]uint8_t83 'S'
flash_page_buffer[1]uint8_t84 'T'
flash_page_buffer[2]uint8_t77 'M'
flash_page_buffer[3]uint8_t51 '3'
flash_page_buffer[4]uint8_t50 '2'
flash_page_buffer[5]uint8_t71 'G'
flash_page_buffer[6]uint8_t52 '4'
flash_page_buffer[7]uint8_t57 '9'
flash_page_buffer[8]uint8_t49 '1'
flash_page_buffer[9]uint8_t86 'V'
flash_page_buffer[10]uint8_t69 'E'
flash_page_buffer[11]uint8_t84 'T'
flash_page_buffer[12]uint8_t32 ' '
flash_page_buffer[13]uint8_t87 'W'
flash_page_buffer[14]uint8_t101 'e'
flash_page_buffer[15]uint8_t97 'a'
flash_page_buffer[16]uint8_t116 't'
flash_page_buffer[17]uint8_t104 'h'
flash_page_buffer[18]uint8_t101 'e'
flash_page_buffer[19]uint8_t114 'r'
flash_page_buffer[20]uint8_t32 ' '
flash_page_buffer[21]uint8_t83 'S'
flash_page_buffer[22]uint8_t116 't'
flash_page_buffer[23]uint8_t97 'a'
flash_page_buffer[24]uint8_t116 't'
flash_page_buffer[25]uint8_t105 'i'
flash_page_buffer[26]uint8_t111 'o'
flash_page_buffer[27]uint8_t110 'n'
flash_page_buffer[28]uint8_t32 ' '
flash_page_buffer[29]uint8_t40 '('
flash_page_buffer[30]uint8_t67 'C'
flash_page_buffer[31]uint8_t41 ')'
flash_page_buffer[32]uint8_t32 ' '
flash_page_buffer[33]uint8_t50 '2'
flash_page_buffer[34]uint8_t48 '0'
flash_page_buffer[35]uint8_t50 '2'
flash_page_buffer[36]uint8_t52 '4'
flash_page_buffer[37]uint8_t32 ' '
flash_page_buffer[38]uint8_t77 'M'
flash_page_buffer[39]uint8_t83 'S'
flash_page_buffer[40]uint8_t111 'o'
flash_page_buffer[41]uint8_t102 'f'
flash_page_buffer[42]uint8_t116 't'
flash_page_buffer[43]uint8_t32 ' '
flash_page_buffer[44]uint8_t82 'R'
flash_page_buffer[45]uint8_t101 'e'
flash_page_buffer[46]uint8_t118 'v'
flash_page_buffer[47]uint8_t46 '.'
flash_page_buffer[48]uint8_t32 ' '
flash_page_buffer[49]uint8_t48 '0'
flash_page_buffer[50]uint8_t46 '.'
flash_page_buffer[51]uint8_t48 '0'
flash_page_buffer[52]uint8_t46 '.'
flash_page_buffer[53]uint8_t48 '0'
flash_page_buffer[54]uint8_t99 'c'
flash_page_buffer[55]uint8_t0 '\0'
flash_page_buffer[56]uint8_t160 ' '
flash_page_buffer[57]uint8_t15 '\017'
flash_page_buffer[58]uint8_t255 'ÿ'
flash_page_buffer[59]uint8_t255 'ÿ'
flash_page_buffer[60]uint8_t255 'ÿ'
flash_page_buffer[61]uint8_t255 'ÿ'
flash_page_buffer[62]uint8_t255 'ÿ'
flash_page_buffer[63]uint8_t255 'ÿ'


Data read in DUAL I/O Mode
flash_page_bufferuint8_t [64]0x20003098 <ucHeap+6584>
flash_page_buffer[0]uint8_t83 'S'
flash_page_buffer[1]uint8_t84 'T'
flash_page_buffer[2]uint8_t77 'M'
flash_page_buffer[3]uint8_t51 '3'
flash_page_buffer[4]uint8_t50 '2'
flash_page_buffer[5]uint8_t71 'G'
flash_page_buffer[6]uint8_t52 '4'
flash_page_buffer[7]uint8_t57 '9'
flash_page_buffer[8]uint8_t49 '1'
flash_page_buffer[9]uint8_t86 'V'
flash_page_buffer[10]uint8_t69 'E'
flash_page_buffer[11]uint8_t84 'T'
flash_page_buffer[12]uint8_t32 ' '
flash_page_buffer[13]uint8_t87 'W'
flash_page_buffer[14]uint8_t101 'e'
flash_page_buffer[15]uint8_t97 'a'
flash_page_buffer[16]uint8_t116 't'
flash_page_buffer[17]uint8_t104 'h'
flash_page_buffer[18]uint8_t101 'e'
flash_page_buffer[19]uint8_t114 'r'
flash_page_buffer[20]uint8_t32 ' '
flash_page_buffer[21]uint8_t83 'S'
flash_page_buffer[22]uint8_t116 't'
flash_page_buffer[23]uint8_t97 'a'
flash_page_buffer[24]uint8_t116 't'
flash_page_buffer[25]uint8_t105 'i'
flash_page_buffer[26]uint8_t111 'o'
flash_page_buffer[27]uint8_t110 'n'
flash_page_buffer[28]uint8_t32 ' '
flash_page_buffer[29]uint8_t40 '('
flash_page_buffer[30]uint8_t67 'C'
flash_page_buffer[31]uint8_t41 ')'
flash_page_buffer[32]uint8_t32 ' '
flash_page_buffer[33]uint8_t50 '2'
flash_page_buffer[34]uint8_t48 '0'
flash_page_buffer[35]uint8_t50 '2'
flash_page_buffer[36]uint8_t52 '4'
flash_page_buffer[37]uint8_t32 ' '
flash_page_buffer[38]uint8_t77 'M'
flash_page_buffer[39]uint8_t83 'S'
flash_page_buffer[40]uint8_t111 'o'
flash_page_buffer[41]uint8_t102 'f'
flash_page_buffer[42]uint8_t116 't'
flash_page_buffer[43]uint8_t32 ' '
flash_page_buffer[44]uint8_t82 'R'
flash_page_buffer[45]uint8_t101 'e'
flash_page_buffer[46]uint8_t118 'v'
flash_page_buffer[47]uint8_t46 '.'
flash_page_buffer[48]uint8_t32 ' '
flash_page_buffer[49]uint8_t48 '0'
flash_page_buffer[50]uint8_t46 '.'
flash_page_buffer[51]uint8_t48 '0'
flash_page_buffer[52]uint8_t46 '.'
flash_page_buffer[53]uint8_t48 '0'
flash_page_buffer[54]uint8_t99 'c'
flash_page_buffer[55]uint8_t13 '\r'
flash_page_buffer[56]uint8_t10 '\n'
flash_page_buffer[57]uint8_t0 '\0'
flash_page_buffer[58]uint8_t255 'ÿ'
flash_page_buffer[59]uint8_t255 'ÿ'
flash_page_buffer[60]uint8_t255 'ÿ'
flash_page_buffer[61]uint8_t255 'ÿ'
flash_page_buffer[62]uint8_t255 'ÿ'
flash_page_buffer[63]uint8_t255 'ÿ'

Thanks in advance

 

4 REPLIES 4
KDJEM.1
ST Employee

Hi @zeboss49 ,

Could you please check the dummy.

As mentioned in the memory datasheet for Fast Read Quad I/O with 4-Byte Address (ECh), the first dummy is M7-M0 should be set to FFh.

KDJEM1_0-1714055846396.png

KDJEM1_1-1714055879664.png

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Need to get SR2.QE = 1 for 4-pin operation/commands to be accepted/viable

If the first data reads fine, and then subsequent data fails, it suggests you're out running the buffering. Reduce the clock speed, or review the mode the memory is in. Perhaps it needs more dummy cycles configured on the memory side to allow it to prefetch more data for rapid output. Sure this material will be in the data sheet. Read it with an eye to understanding what it's communicating to you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you for your reply.

The dummy byte (alternate byte) and dummy cycles are set according to the device data sheet.

 

Thank you for your answer.

The data issue is not related to the corrupted bytes position in the data stream.

%oving them in the stream does not change anything.

The \r\n pair is always corrupted.

I noticed that they are the only bytes in the stream to have the 4 MSB set to 0.

The tests were ran using a breadboard, and this could be the faulty point.

I'l test again with the PCB and post an update to tell you wether it solves the issue or not.

I'm suspecting ringing with the bread board.