2015-07-02 12:57 AM
Hi:
i use the DMA interrupt to send 8 byte data and receive 9 byte,it can only executes once,but when i debug it step by step,it works well。i'm so confused.Sorry for my poor english.
Here is my code,is there something important i miss?Thank you for your patience
void DMA1_Channel4_IRQHandler(void) /* DMA TX ,interrupt after all the datas send over*/
{
DMA_ClearFlag(DMA1_FLAG_TC4);
DMA_ClearITPendingBit(DMA1_IT_TC4);
DMA_Cmd(DMA1_Channel4,DISABLE);
}
void DMA1_Channel5_IRQHandler(void)
{
DMA_ClearITPendingBit(DMA1_IT_TC5);
DMA_Cmd(DMA1_Channel5, DISABLE); /*Enable DMA RX*/
DMA_SetCurrDataCounter(DMA1_Channel5,9);
DMA_Cmd(DMA1_Channel5, ENABLE);
/*
here is data process, 9 byte datas
*/
if(TempHumidity.AddressSelectFlag == 0) /* Uart_Send_Buffer is the buffer connected to USART1->DR*/
{
TempHumidity.AddressSelectFlag = 1;
MemCopy(Uart_Send_Buffer,TempHumidity.UartSendBufferA,8);
}
else
{
TempHumidity.AddressSelectFlag = 0;
MemCopy(Uart_Send_Buffer,TempHumidity.UartSendBufferB,8);
}
DMA_Cmd(DMA1_Channel4, DISABLE);
DMA_SetCurrDataCounter(DMA1_Channel4,8);
DMA_Cmd(DMA1_Channel4, ENABLE); /*Enable DMA TX*/
}
2015-07-02 08:17 AM
Please don't spam other threads, that's not how the forum works.
If it works under the debugger look carefully at the timing and potential race conditions.I would try to qualify the interrupt sources, and perhaps use GPIO's and a logic analyzer to understand the failure and timing of things.2015-07-02 08:54 AM
sorry,i'm a sophmore from China,before asking this question,i've use the
oscilloscope to test it,and read the datasheet many times,i guess the error must be the timing or important flags i ignored.
i have another way to realize my goal.but i just cannot understand why this way cannot get the right answer. Thanks for your reply,i'll borrow a logic analyzer to test it. Actually,this is my first time to use english to ask questions.2015-07-02 10:22 AM
Actually,this is my first time to use english to ask questions.
You're English is very good, don't worry about it.You might want to look at how you handle synchronization issues here, if the data doesn't come back quite as you expect, or it starts out of sync. There's a potential for it to dead-lock, perhaps, where it doesn't start a new batch of bytes, and is still waiting for 1 or 2 to arrive. Consider a timeout.