2021-11-08 11:58 AM
Hello,
As mentioned in DMA is not working on STM32H7 devices
I applied solution before DMA receive
SCB_InvalidateDCache_by_Addr((uint32_t*)(((uint32_t)rx_buffer) & ~(uint32_t)0x1F), RX_LENGTH+32);
but it just get stuck in this instruction and not executing anything after this instruction
below is my code for reference
uint32_t Recbuf[10] __attribute__ ((aligned (32)));
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_DFSDM1_Init();
MX_USART3_UART_Init();
MX_UART5_Init();
MX_CRC_Init();
MX_UART4_Init();
MX_UART7_Init();
MX_X_CUBE_AI_Init();
/* USER CODE BEGIN 2 */
void v_Set_to_Receive_From_UARTP(void){
SCB_InvalidateDCache_by_Addr((uint32_t*)(((uint32_t)Recbuf) & ~(uint32_t)0x1F), sizeof(Recbuf));
HAL_UART_Receive_DMA(&huart3, (uint8_t *)&Recbuf,10);
}
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2021-11-08 01:41 PM
You didn't call SCB_InvalidateDCache_by_Addr or HAL_UART_Receive_DMA. You just defined a function which calls it from within the main() function, which is weird. But you don't call that function anywhere. Take out the v_Set_to_Receive_From_UARTP line and the closing bracket.
2021-11-08 02:10 PM
Does it Hard Fault?
Seems some inconsistencies in byte/word sizing of things. Make the data areas large enough that things before/after are not involved.
One should probably very carefully unpack the addresses being used and the span/scope of the invalidate.
DMA has expectations about the memory ranges used. Make sure you're using a region that the DMA can use, and that it's now throwing errors or status warnings.
2021-11-10 05:09 AM
you have to move the function declaration out of the main init sequence...
you should call it from init..
uint32_t Recbuf[10] __attribute__ ((aligned (32)));
void v_Set_to_Receive_From_UARTP(void)
{
SCB_InvalidateDCache_by_Addr((uint32_t*)(((uint32_t)Recbuf) & ~(uint32_t)0x1F), sizeof(Recbuf));
HAL_UART_Receive_DMA(&huart3, (uint8_t *)&Recbuf,10);
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_DFSDM1_Init();
MX_USART3_UART_Init();
MX_UART5_Init();
MX_CRC_Init();
MX_UART4_Init();
MX_UART7_Init();
MX_X_CUBE_AI_Init();
/* USER CODE BEGIN 2 */
v_Set_to_Receive_From_UARTP();
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}