diff --git a/.cproject b/.cproject index 44a6a59..9460ebb 100644 --- a/.cproject +++ b/.cproject @@ -44,10 +44,10 @@ + - @@ -76,11 +76,11 @@ - - + + @@ -131,6 +131,7 @@ + @@ -159,11 +160,11 @@ - - + + diff --git a/.mxproject b/.mxproject index 0719fcd..5da0d46 100644 --- a/.mxproject +++ b/.mxproject @@ -1,7 +1,7 @@ [PreviousGenFiles] -HeaderPath=/mnt/userdata/compi/work/private/stm32/f407ve_packetusart_c/Inc +HeaderPath=/home/abody/Private/work/private/f407ve_hs_uart/projects/f407ve_packetusart_c/Inc HeaderFiles=gpio.h;crc.h;dma.h;sys.h;usart.h;stm32f4xx_it.h;stm32_assert.h;stm32f4xx_hal_conf.h;main.h; -SourcePath=/mnt/userdata/compi/work/private/stm32/f407ve_packetusart_c/Src +SourcePath=/home/abody/Private/work/private/f407ve_hs_uart/projects/f407ve_packetusart_c/Src SourceFiles=gpio.c;crc.c;dma.c;sys.c;usart.c;stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; [PreviousLibFiles] diff --git a/STM32F407VETX_FLASH.ld b/STM32F407VETX_FLASH.ld index bdb4029..c91d847 100644 --- a/STM32F407VETX_FLASH.ld +++ b/STM32F407VETX_FLASH.ld @@ -56,8 +56,8 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ +_Min_Heap_Size = 0x200 ; /* required amount of heap */ +_Min_Stack_Size = 0x400 ; /* required amount of stack */ /* Memories definition */ MEMORY diff --git a/Src/dma.c b/Src/dma.c index 3ff9e3b..bf00776 100644 --- a/Src/dma.c +++ b/Src/dma.c @@ -61,16 +61,25 @@ void MX_DMA_Init(void) LL_DMA_SetPeriphIncMode(DMA2, LL_DMA_STREAM_4, LL_DMA_PERIPH_INCREMENT); /* Set memory increment mode */ - LL_DMA_SetMemoryIncMode(DMA2, LL_DMA_STREAM_4, LL_DMA_MEMORY_INCREMENT); + LL_DMA_SetMemoryIncMode(DMA2, LL_DMA_STREAM_4, LL_DMA_MEMORY_NOINCREMENT); /* Set peripheral data width */ - LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_4, LL_DMA_PDATAALIGN_BYTE); + LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_4, LL_DMA_PDATAALIGN_WORD); /* Set memory data width */ - LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_4, LL_DMA_MDATAALIGN_BYTE); + LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_4, LL_DMA_MDATAALIGN_WORD); - /* Disable FIFO mode */ - LL_DMA_DisableFifoMode(DMA2, LL_DMA_STREAM_4); + /* Enable FIFO mode */ + LL_DMA_EnableFifoMode(DMA2, LL_DMA_STREAM_4); + + /* Set FIFO threshold */ + LL_DMA_SetFIFOThreshold(DMA2, LL_DMA_STREAM_4, LL_DMA_FIFOTHRESHOLD_FULL); + + /* Set memory burst size */ + LL_DMA_SetMemoryBurstxfer(DMA2, LL_DMA_STREAM_4, LL_DMA_MBURST_SINGLE); + + /* Set peripheral burst size */ + LL_DMA_SetPeriphBurstxfer(DMA2, LL_DMA_STREAM_4, LL_DMA_PBURST_SINGLE); /* Configure DMA request MEMTOMEM_DMA2_Stream3 */ @@ -93,13 +102,22 @@ void MX_DMA_Init(void) LL_DMA_SetMemoryIncMode(DMA2, LL_DMA_STREAM_3, LL_DMA_MEMORY_INCREMENT); /* Set peripheral data width */ - LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_3, LL_DMA_PDATAALIGN_BYTE); + LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_3, LL_DMA_PDATAALIGN_WORD); /* Set memory data width */ - LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_3, LL_DMA_MDATAALIGN_BYTE); + LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_3, LL_DMA_MDATAALIGN_WORD); - /* Disable FIFO mode */ - LL_DMA_DisableFifoMode(DMA2, LL_DMA_STREAM_3); + /* Enable FIFO mode */ + LL_DMA_EnableFifoMode(DMA2, LL_DMA_STREAM_3); + + /* Set FIFO threshold */ + LL_DMA_SetFIFOThreshold(DMA2, LL_DMA_STREAM_3, LL_DMA_FIFOTHRESHOLD_FULL); + + /* Set memory burst size */ + LL_DMA_SetMemoryBurstxfer(DMA2, LL_DMA_STREAM_3, LL_DMA_MBURST_SINGLE); + + /* Set peripheral burst size */ + LL_DMA_SetPeriphBurstxfer(DMA2, LL_DMA_STREAM_3, LL_DMA_PBURST_SINGLE); /* DMA interrupt init */ /* DMA1_Stream1_IRQn interrupt configuration */ diff --git a/Src/main.c b/Src/main.c index 00ed151..95b7f6d 100644 --- a/Src/main.c +++ b/Src/main.c @@ -27,6 +27,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "application.h" /* USER CODE END Includes */ @@ -98,7 +99,7 @@ int main(void) MX_USART6_UART_Init(); MX_CRC_Init(); /* USER CODE BEGIN 2 */ - + MainLoop(); /* USER CODE END 2 */ /* Infinite loop */ diff --git a/application/config.h b/application/config.h index 92c392f..6d4c8f3 100644 --- a/application/config.h +++ b/application/config.h @@ -9,7 +9,6 @@ #define CONFIG_H_ #define USARTCOUNT 4 -#define CRCTASKCOUNT (USARTCOUNT * 2) #define USART1_OFFSET 0 #define USART2_OFFSET 1 #define USART3_OFFSET 2 diff --git a/f407ve_packetusart_c.ioc b/f407ve_packetusart_c.ioc index 5579714..32266e3 100644 --- a/f407ve_packetusart_c.ioc +++ b/f407ve_packetusart_c.ioc @@ -1,24 +1,30 @@ #MicroXplorer Configuration settings - do not modify Dma.MEMTOMEM.10.Direction=DMA_MEMORY_TO_MEMORY -Dma.MEMTOMEM.10.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.MEMTOMEM.10.FIFOMode=DMA_FIFOMODE_ENABLE +Dma.MEMTOMEM.10.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL Dma.MEMTOMEM.10.Instance=DMA2_Stream4 -Dma.MEMTOMEM.10.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.MEMTOMEM.10.MemInc=DMA_MINC_ENABLE +Dma.MEMTOMEM.10.MemBurst=DMA_MBURST_SINGLE +Dma.MEMTOMEM.10.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.MEMTOMEM.10.MemInc=DMA_MINC_DISABLE Dma.MEMTOMEM.10.Mode=DMA_NORMAL -Dma.MEMTOMEM.10.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.MEMTOMEM.10.PeriphBurst=DMA_PBURST_SINGLE +Dma.MEMTOMEM.10.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.MEMTOMEM.10.PeriphInc=DMA_PINC_ENABLE Dma.MEMTOMEM.10.Priority=DMA_PRIORITY_LOW -Dma.MEMTOMEM.10.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.MEMTOMEM.10.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst Dma.MEMTOMEM.11.Direction=DMA_MEMORY_TO_MEMORY -Dma.MEMTOMEM.11.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.MEMTOMEM.11.FIFOMode=DMA_FIFOMODE_ENABLE +Dma.MEMTOMEM.11.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL Dma.MEMTOMEM.11.Instance=DMA2_Stream3 -Dma.MEMTOMEM.11.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.MEMTOMEM.11.MemBurst=DMA_MBURST_SINGLE +Dma.MEMTOMEM.11.MemDataAlignment=DMA_MDATAALIGN_WORD Dma.MEMTOMEM.11.MemInc=DMA_MINC_ENABLE Dma.MEMTOMEM.11.Mode=DMA_NORMAL -Dma.MEMTOMEM.11.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.MEMTOMEM.11.PeriphBurst=DMA_PBURST_SINGLE +Dma.MEMTOMEM.11.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.MEMTOMEM.11.PeriphInc=DMA_PINC_ENABLE Dma.MEMTOMEM.11.Priority=DMA_PRIORITY_LOW -Dma.MEMTOMEM.11.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.MEMTOMEM.11.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst Dma.Request0=USART6_RX Dma.Request1=USART6_TX Dma.Request10=MEMTOMEM