AnsweredAssumed Answered

MPU regions and DMA

Question asked by greenwood.greg on May 8, 2018

I am confused over the inability to successfully setup an MPU region for the area that the DMA is using.  I am trying to get around having to use Clean and Invalidate Cache like so to guaranty the data is passed correctly:

    SCB_CleanDCache_by_Addr((uint32_t *)EclFrame, ((BytesToSend+31)/32)*32); //works

    result = HAL_UART_Transmit_DMA(&UartHandle, (uint8_t *) EclFrame, BytesToSend);


    result = HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)EclFrame, BufferSize);

    SCB_InvalidateDCache_by_Addr((uint32_t *)EclFrame, ((BufferSize+31)/32)*32); // works


I have tried to setup a region for RAM_D1 like so:

  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x24000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; //also tried NOT
  MPU_InitStruct.Number = MPU_REGION_NUMBER4;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x00;




with the result being that the transmit sends the wrong data.  I am not sure about receive since this is used in a command-response sequence hence sending the wrong data out means no data back.  There are three other memory regions setup and they are working fine so I do not get why this region should have a problem.