STM32H7 USART RX DMA is not working

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
s_sergiu
Posts: 77
Joined: 10 Jan 2012 15:09

STM32H7 USART RX DMA is not working

#1 Post by s_sergiu » 26 Apr 2020 14:13

Hello,

I use STM32H743Zi (Nucleo board).
I believe it is some issues with wrong compiling registers preventing working of DMA controller. I use same code
for STM32F4 with changes specific to H7. Code below:

sub procedure DMA2_UART3_RX() iv IVT_INT_DMA2_STR2 ics ICS_AUTO

DMA2_LIFCR.CTCIF2=1 ' clear the int or it will not restart
DMA2_S7CR.EN=1 ' enable again the stream

end sub

sub procedure SBUS_DMA_Init()

rem Enable peripherals CLOCK
RCC_AHB1ENR.DMA2EN=1
RCC_AHB2ENR.SRAM1EN=1
RCC_AHB2ENR.SRAM2EN=1
RCC_AHB2ENR.SRAM3EN=1
rem Disable the DMA Stream by resetting EN bit
DMA2_S2CR.EN = 0
while (DMA2_S2CR.EN=1) wend
rem All Stream Status dedicated registers to be cleared
DMA2_LIFCR.CTCIF2=1
rem Set peripheral port register address
DMA2_S2PAR = @USART3_RDR
rem Set memory address
DMA2_S2M0AR = @tmp_sbus
rem total number of data items is 25 bytes
DMA2_S2NDTR = 1 '25
rem Direct mode
DMA2_S2FCR.DMDIS=0
rem Select DMAMUX channel 45 corresponding to USART_RX_DMA; C10 is stream 2 of DMA2
DMAMUX1_C10CR.DMAREQ_ID6 = 0
DMAMUX1_C10CR.DMAREQ_ID5 = 1
DMAMUX1_C10CR.DMAREQ_ID4 = 0
DMAMUX1_C10CR.DMAREQ_ID3 = 1
DMAMUX1_C10CR.DMAREQ_ID2 = 1
DMAMUX1_C10CR.DMAREQ_ID1 = 0
DMAMUX1_C10CR.DMAREQ_ID0 = 1
rem Config the stream priority (to Very High)
DMA2_S2CR.PL1=1
DMA2_S2CR.PL0=1
rem Memory data size to 8 bit
DMA2_S2CR.MSIZE1=0
DMA2_S2CR.MSIZE0=0
rem Peripheral data size to 8 bit
DMA2_S2CR.PSIZE1=0
DMA2_S2CR.PSIZE0=0
rem Memory increment mode
DMA2_S2CR.MINC = 1
rem Peripheral increment mode
DMA2_S2CR.PINC = 0
rem Burst mode PERIPHERAL
DMA2_S2CR.PBURST1=0
DMA2_S2CR.PBURST0=0
REM Burst mode Memory
DMA2_S2CR.MBURST1=0
DMA2_S2CR.MBURST0=0
rem Data transfer direction (peripheral to memory)
DMA2_S2CR.DIR1=0
DMA2_S2CR.DIR0=0
rem Circular mode
DMA2_S2CR.CIRC=1
rem FIFO Mode ENABLE(DMDIS) ;TRESHOLD=FULL FIF0(11)
DMA2_S2FCR.DMDIS=1
DMA2_S2FCR.FTH1=1
DMA2_S2FCR.FTH0=1
rem peripheral flow controller ,DMA flow
DMA2_S2CR.PFCTRL=0
rem Transfer complete interrupt enable
DMA2_S2CR.TCIE=1
'****************************************************************
rem DMA mode is enabled for reception
USART3_CR3.DMAR=1
'****************************************************************
EnableInterrupts() ' Enables the processor interrupt
NVIC_IntEnable(IVT_INT_DMA2_STR2) ' Enable DMA2_Stream2 interrupt
'***************************************************************
rem Stream enable (start the DMA Stream2)
DMA2_S2CR.EN=1

end sub


Any help is appreciated.
Sergiu

Post Reply

Return to “mikroBasic PRO for ARM General”