2020-02-09 09:26 PM
In community they have asked to disable D cache (https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices). How to disable D cache globally. I made the necessary changes in the linker script. I am using system workbench for stm and stm32cubeMX.
DMA stream0 for adc1 6 channels.
DMA stream1 for adc3.
sample code
#include "main.h"
#include "usb_device.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc3;
DMA_HandleTypeDef hdma_adc1;
DMA_HandleTypeDef hdma_adc3;
FDCAN_HandleTypeDef hfdcan1;
UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_ADC1_Init(void);
static void MX_ADC3_Init(void);
static void MX_FDCAN1_Init(void);
static void MX_USART3_UART_Init(void);
void MPU_RegionConfig(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint32_t adc[6],temp[6],adc2[6];
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
//char a[3]={'h','i'};
/* USER CODE END 1 */
/* 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 */
// MPU_RegionConfig();
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_ADC3_Init();
MX_FDCAN1_Init();
MX_USART3_UART_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_DMA(&hadc1,(uint32_t*) adc,6);
HAL_ADC_Start_DMA(&hadc3,(uint32_t*) adc2,6);
// HAL_ADCEx_Calibration_Start(&hadc1,ADC_CALIB_OFFSET, ADC_SINGLE_ENDED );
// HAL_ADC_Start(&hadc1);
//
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
// (HAL_ADC_PollForConversion(&hadc1,100));
// adc[0] = HAL_ADC_GetValue(&hadc1);
//
// (HAL_ADC_PollForConversion(&hadc1,100));
// adc[1] = HAL_ADC_GetValue(&hadc1);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2020-03-09 02:53 AM
Hello,
I have made a test to check and I don’t have any problem to read the values for ADC1 (DMA stream 0)
You should change the memory address, as shown in Figure (when using IAR)
Please see the RM0433 Rev 6 (page 101, 128) for more clarification
Best Regards,
2020-05-07 01:11 AM
Thank you.