Forum > Embedded - ARM

stm32f103 dma problem [SOLVED]

(1/8) > >>

diego bertotti:
hi

im trying bluepill board

using  unit stm32f103fw
{ Converted from STM FWlib

 Contributors:
  Jeppe Johansen
  Bernd Mueller
  Valerio Turrini with really small adjustments.....
}

when i use dma channels system hangs


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  DMA_InitTypeDef.DMA_BufferSize:= 64;  DMA_InitTypeDef.DMA_DIR:= DMA_DIR_PeripheralSRC;  DMA_InitTypeDef.DMA_M2M:= DMA_M2M_Disable;  DMA_InitTypeDef.DMA_MemoryBaseAddr:=  @RXbuffer1;  DMA_InitTypeDef.DMA_MemoryDataSize:= DMA_MemoryDataSize_Byte;  DMA_InitTypeDef.DMA_MemoryInc:= DMA_MemoryInc_Enable;  DMA_InitTypeDef.DMA_Mode:= DMA_Mode_Circular;  DMA_InitTypeDef.DMA_PeripheralBaseAddr:= @Usart1.DR;  DMA_InitTypeDef.DMA_PeripheralDataSize:= DMA_PeripheralDataSize_Byte;  DMA_InitTypeDef.DMA_PeripheralInc:= DMA_PeripheralInc_Disable;  DMA_InitTypeDef.DMA_Priority:= DMA_Priority_Medium;  DMA_Init(DMA1.Channel[5], DMA_InitTypeDef); //USART1_RX  DMA_CMD(DMA1.Channel[5], Enabled); 
or even hangs if i use only the dma_deinit function

if i comment out the last 2 lines, dont hang, but ovbiously, dont work the dma controller, but all the rest code work fine


in the stm32f10x_md file i found this ┬┐bug?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- TDMARegisters = record  ISR,  IFCR: longword;  //Channel: array[0..7] of TDMAChannel; //wrong!! 8 channels space but have only 7  Channel: array[0..6] of TDMAChannel;  //diego bertotti 7/7/2020 end; 

 thanks in advance for any help/suggestions

 

MiR:
Looking at the datasheet 0..6 is correct, but better values would have been 1..7 as the DMA channels are numbered 1-7 in the reference manual.

Not sure if you took the offset of one into account in your code, DMA1.Channel[5] actually means use Channel6

Michael

MiR:
Again, from the reference manual:

USART1.RX is attached to Channel5 which means you will have to take index '4'

diego bertotti:
thanks for replys

i try with index 4 (you are right). same problem.

remember, i have the same problem, using the DMA_deinit function. in this case is not important the index value, is just an initilization, and hangs too.

i fix index form 0 to 6 because this code


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure DMA_DeInit(var DMAy_Channelx: TDMAChannel); begin   DMAy_Channelx.CCR:= DMAy_Channelx.CCR and (not(CCR_ENABLE_SET));   DMAy_Channelx.CCR:=0;   DMAy_Channelx.CNDTR:=0;   DMAy_Channelx.CPAR:=0;   DMAy_Channelx.CMAR:=0;   if @DMAy_Channelx = @DMA1.Channel[0] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel1_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[1] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel2_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[2] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel3_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[3] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel4_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[4] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel5_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[5] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel6_IT_Mask   else if @DMAy_Channelx = @DMA1.Channel[6] then      DMA1.IFCR := DMA1.IFCR or DMA1_Channel7_IT_Mask   else if @DMAy_Channelx = @DMA2.Channel[0] then      DMA2.IFCR := DMA2.IFCR or DMA2_Channel1_IT_Mask   else if @DMAy_Channelx = @DMA2.Channel[1] then      DMA2.IFCR := DMA2.IFCR or DMA2_Channel2_IT_Mask   else if @DMAy_Channelx = @DMA2.Channel[2] then      DMA2.IFCR := DMA2.IFCR or DMA2_Channel3_IT_Mask   else if @DMAy_Channelx = @DMA2.Channel[3] then      DMA2.IFCR := DMA2.IFCR or DMA2_Channel4_IT_Mask   else if @DMAy_Channelx = @DMA2.Channel[4] then      DMA2.IFCR := DMA2.IFCR or DMA2_Channel5_IT_Maskend;     
look for example channel 1 use index 0!

MiR:
Have you tried running your deinit code in a debugger?

When I compare your De-Init Code to the original code in the C-Library it looks like a 1:1 translation so there does not seem to be an issue with the code itself.

In the debugger you will see easily if some interrupt triggers or you get some other exception

Navigation

[0] Message Index

[#] Next page

Go to full version