簡體   English   中英

使用 STM32F103 微控制器 (Cortex-M3) 重新編程 DMA 起始地址

[英]Reprogramming DMA start address using STM32F103 microcontroller (Cortex-M3)

下面的 IRQ 處理程序會耗盡傳入 32 字節數據的 USART3。 第一個 IRQ TC 事件讀取前 6 個字節,然后重新編程 DMA 引擎以讀取最后 24 個字節。 第二個 TC 重新編組它以再次讀取標題。此方法將允許使用 DMA 的可變長度消息。 但是我似乎無法更改 DMA 起始地址。 我希望能夠將每條消息存儲在一個單獨的緩沖區中,但是它只是在收到每條消息時覆蓋第一個緩沖區。 我究竟做錯了什么? 微控制器是 STM32F103ze(Cortex-M3)。

void DMA1_Channel3_IRQHandler(void)
{
    uint32_t tmpreg = 0;
     /* Test on DMA1 Channel3 Transfer Complete interrupt */
     if(DMA_GetITStatus(DMA1_IT_TC3)) 
     {
          if (rx3_dma_state == RECIEVE_HEADER )
          {
               DMA_Cmd(DMA1_Channel3, DISABLE);/* Disable DMA1_Channel2 transfer*/
               // Now that have received the header. Configure the DMA engine to receive
               // the data portion of the message
               DMA_SetCurrDataCounter(DMA1_Channel3,26);
               DMA_Cmd(DMA1_Channel3, ENABLE);
          } else if ( rx3_dma_state == RECIEVE_MSG )
          {
               //CurrDataCounterEnd3 = DMA_GetCurrDataCounter(DMA1_Channel3);
               DMA_Cmd(DMA1_Channel3, DISABLE);
               /* Get Current Data Counter value after complete transfer */
               USART3_Rx_DMA_Channel_Struct->CMAR = (uint32_t) RxBuffer3LookUp[rx_buffer_index];
               DMA_SetCurrDataCounter(DMA1_Channel3, 6);
               DMA_Cmd(DMA1_Channel3,ENABLE);
               // Set up DMA to write into the next buffer slot (1 of 8)
               ++rx_buffer_index;
               rx_buffer_index %= 8;
          }
          /* Clear DMA1 Channel6 Half Transfer, Transfer Complete and Global interrupt pending bits */
          DMA_ClearITPendingBit(DMA1_IT_GL3);
     }      
     // Update the state to read fake header of 6 bytes
     // or to read the fake data section of the message 26 bytes
     ++rx3_dma_state;
     rx3_dma_state %= 2;
     isr_sem_send(dma_usart3_rx_sem);
}

你說:

...重新編程 DMA 引擎以讀取最后 24 個字節。

但你的代碼說:

DMA_SetCurrDataCounter(DMA1_Channel3,26);

那正確嗎? 是 24 還是 26?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM