<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic TxUnderrun while writing to SD card from LPC1788-based system in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/TxUnderrun-while-writing-to-SD-card-from-LPC1788-based-system/m-p/1658756#M52762</link>
    <description>&lt;P&gt;My intent was to implement FatFS, so I used an example from “&lt;STRONG&gt;lpcopen_2_10_lpcxpresso_ea_devkit_1788&lt;/STRONG&gt;” (I have Embedded Artists LPC1788 OEM board rev. E and base board rev. C1). Because nothing was working, I disabled the DMA and ended up calling “&lt;STRONG&gt;Chip_SDMMC_WriteBlocks&lt;/STRONG&gt;” directly.&lt;/P&gt;&lt;P&gt;The call to “&lt;STRONG&gt;Chip_SDMMC_Acquire&lt;/STRONG&gt;” succeeds and “&lt;STRONG&gt;SDMMC_CARD_T&lt;/STRONG&gt;” structure seems to be populated correctly, but this is the end of successful part. Problem occurs in the next steps:&lt;/P&gt;&lt;P&gt;1. Having acquired the card, I invoke this line (simplified):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Chip_SDMMC_WriteBlocks( pSDC, pCardInfo, “Abcdefghijk”, 0, 1 );&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Execution then enters the code located in LPCOpen, version 2.10:&lt;/P&gt;&lt;P&gt;2. As data transfer is enabled in MCIDataCtrl (0x400C 002C), interrupt is triggered with MCIStatus of 282624 (bit 18: Transmit FIFO empty, bit 14: Transmit FIFO half empty, and bit 12: Data transmit in progress)&lt;/P&gt;&lt;P&gt;3. Interrupt handler enters “&lt;STRONG&gt;Chip_SDC_WriteFIFO&lt;/STRONG&gt;” function (sdc_17xx_40xx.c) executing this code (simplified by me):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for (start = 0; start &amp;lt;= 7; start++) {&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;pSDC-&amp;gt;FIFO[start] = *pSrc;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pSrc++;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;4. After the first run through this loop: FIFO[0] = 0x64636241 (i. e. “Abcd”) according to debugger, ALL sixteen FIFO registers gain value 0x64636241 and MCIStatus changes to 16 (TxUnderrun)&lt;/P&gt;&lt;P&gt;5. Next interrupt occurs with MCIStatus of TxUnderrun and aborts the transfer due to error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m looking for advice regarding any of these:&lt;/P&gt;&lt;P&gt;Q1: Why writing a single 4-byte integer to FIFO[0] affects all 16 of them? Does the debugger display it wrong?&lt;/P&gt;&lt;P&gt;Q2: Why writing a single 4-byte integer to FIFO[0] instantly triggers TxUnderrun? I verified that it’s not caused due to manually/slowly stepping through the code in debugger by moving breakpoint further in the path of execution.&lt;/P&gt;&lt;P&gt;Q3: Is writing to eight FIFOs in a loop a correct practice? To compare with UART: function “&lt;STRONG&gt;Chip_UART_SendByte&lt;/STRONG&gt;” (uart_17xx_40xx.c) sends one byte at time:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;pUART-&amp;gt;THR = (uint32_t) data;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Q4: Is there any better code sample I can use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eugene&lt;/P&gt;</description>
    <pubDate>Sun, 28 May 2023 15:35:56 GMT</pubDate>
    <dc:creator>Eugene723</dc:creator>
    <dc:date>2023-05-28T15:35:56Z</dc:date>
    <item>
      <title>TxUnderrun while writing to SD card from LPC1788-based system</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/TxUnderrun-while-writing-to-SD-card-from-LPC1788-based-system/m-p/1658756#M52762</link>
      <description>&lt;P&gt;My intent was to implement FatFS, so I used an example from “&lt;STRONG&gt;lpcopen_2_10_lpcxpresso_ea_devkit_1788&lt;/STRONG&gt;” (I have Embedded Artists LPC1788 OEM board rev. E and base board rev. C1). Because nothing was working, I disabled the DMA and ended up calling “&lt;STRONG&gt;Chip_SDMMC_WriteBlocks&lt;/STRONG&gt;” directly.&lt;/P&gt;&lt;P&gt;The call to “&lt;STRONG&gt;Chip_SDMMC_Acquire&lt;/STRONG&gt;” succeeds and “&lt;STRONG&gt;SDMMC_CARD_T&lt;/STRONG&gt;” structure seems to be populated correctly, but this is the end of successful part. Problem occurs in the next steps:&lt;/P&gt;&lt;P&gt;1. Having acquired the card, I invoke this line (simplified):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Chip_SDMMC_WriteBlocks( pSDC, pCardInfo, “Abcdefghijk”, 0, 1 );&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Execution then enters the code located in LPCOpen, version 2.10:&lt;/P&gt;&lt;P&gt;2. As data transfer is enabled in MCIDataCtrl (0x400C 002C), interrupt is triggered with MCIStatus of 282624 (bit 18: Transmit FIFO empty, bit 14: Transmit FIFO half empty, and bit 12: Data transmit in progress)&lt;/P&gt;&lt;P&gt;3. Interrupt handler enters “&lt;STRONG&gt;Chip_SDC_WriteFIFO&lt;/STRONG&gt;” function (sdc_17xx_40xx.c) executing this code (simplified by me):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for (start = 0; start &amp;lt;= 7; start++) {&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;pSDC-&amp;gt;FIFO[start] = *pSrc;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pSrc++;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;4. After the first run through this loop: FIFO[0] = 0x64636241 (i. e. “Abcd”) according to debugger, ALL sixteen FIFO registers gain value 0x64636241 and MCIStatus changes to 16 (TxUnderrun)&lt;/P&gt;&lt;P&gt;5. Next interrupt occurs with MCIStatus of TxUnderrun and aborts the transfer due to error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m looking for advice regarding any of these:&lt;/P&gt;&lt;P&gt;Q1: Why writing a single 4-byte integer to FIFO[0] affects all 16 of them? Does the debugger display it wrong?&lt;/P&gt;&lt;P&gt;Q2: Why writing a single 4-byte integer to FIFO[0] instantly triggers TxUnderrun? I verified that it’s not caused due to manually/slowly stepping through the code in debugger by moving breakpoint further in the path of execution.&lt;/P&gt;&lt;P&gt;Q3: Is writing to eight FIFOs in a loop a correct practice? To compare with UART: function “&lt;STRONG&gt;Chip_UART_SendByte&lt;/STRONG&gt;” (uart_17xx_40xx.c) sends one byte at time:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;pUART-&amp;gt;THR = (uint32_t) data;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Q4: Is there any better code sample I can use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eugene&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 15:35:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/TxUnderrun-while-writing-to-SD-card-from-LPC1788-based-system/m-p/1658756#M52762</guid>
      <dc:creator>Eugene723</dc:creator>
      <dc:date>2023-05-28T15:35:56Z</dc:date>
    </item>
  </channel>
</rss>

