아래의 IRQ 처리기는 들어오는 32 Byes의 USART3을 배출합니다. 첫 번째 IRQ TC 이벤트는 처음 6 바이트를 읽은 다음 DMA 엔진을 다시 프로그래밍하여 마지막 24 바이트를 읽습니다. 두 번째 TC는 헤더를 다시 읽도록이를 다시 그립니다.이 방법은 DMA를 사용하는 가변 길이의 메시지를 허용합니다. 그러나 나는 DMA 시작 주소를 변경할 수있을 것 같지 않습니다. 나는 각 메시지를 별도의 버퍼에 저장할 수 있기를 원하지만 각 메시지를 수신하면 첫 번째 버퍼를 씁니다. 내가 도대체 뭘 잘못하고있는 겁니까? 마이크로 컨트롤러는 STM32F103ze (Cortex-M3)이다.STM32F103 마이크로 컨트롤러 (Cortex-M3)를 사용하여 DMA 시작 주소를 다시 프로그래밍
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);
}
"마지막 26 바이트를 읽도록 DMA 엔진을 다시 프로그래밍"이라고 말해야합니다. 그것이하는 일. 그러나 DMA tranfer는 버퍼의 6 바이트가 아닌 버퍼의 시작에서 시작됩니다. 또한 if 문 아래에서 "rx3_dma_state == RECIEVE_MSG"는 버퍼 어레이의 다음 슬롯에서 다음 DMA xfer를 시작하기 위해 CMAR 레지스터를 다시 프로그래밍하지만 전송 된 데이터가 항상 표시되는 버텍스별로이를 알지 못합니다 RxBuffer3 [0]. 버퍼는 "char RxBuffer [8] [128]"로 정의됩니다. DMA 전송 시작 크기 만 DMA 전송 크기를 재구성하는 데 문제가 없습니다. – iwishujoy