2022-06-14 01:19 AM
One of the variint main(void)
{
/* USER CODE BEGIN 1 */
/* 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 */
MX_GPIO_Init();
MX_DMA_Init();
MX_DAC1_Init();
MX_TIM6_Init();
/* USER CODE BEGIN 2 */
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
HAL_DAC_Start(&hdac1, DAC_CHANNEL_2);
uint16_t sinewave[60];
uint16_t i;
for(i=0;i<60;i++){
sinewave[i]=sin(i/60.0*2*3.1415926)*500+1000;
}
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1,(uint32_t *)sinewave,60,DAC_ALIGN_12B_R);
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_2,(uint32_t *)sinewave,60,DAC_ALIGN_12B_R);
if (HAL_TIM_Base_Start(&htim6) != HAL_OK){
Error_Handler();
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
ants of the code in HAL:
2022-06-23 12:44 PM
Pin P4 without DAC reproduces the signal in OUTPUT mode
2022-06-24 03:29 AM
> RCC->AHB1ENR |= (RCC_AHB1ENR_DMA1EN | RCC_APB1ENR1_TIM6EN );
This does not enable TIM6 clock.
Whenever in doubts, read out and check the involved peripheral registers content.
Proceed step by step. Try a simple implementation first, using DAC without trigger (DAC_CR.TENx=0), writing various values into DAC_DHRx, maybe even manually in debugger.
JW
2022-06-24 03:33 AM
Yes! Of course, PA4 is connected directly to A2. Excuse me!
2022-06-24 03:34 AM
And it works in high/low mode! But there is no DAC signal.
2022-06-24 03:53 AM
There are no jumpers! Have I answered all the questions?
2022-06-24 04:28 AM
Please note that as soon as the thread is longer than 10 posts, there is a "More answers" at the 10th post and you have to click on it.
Sometimes, this link is not displayed, because the software ST uses here is crap, and you have to reload the thread.
JW
@Laura C.
2022-06-24 04:29 AM
Please note that as soon as the thread is longer than 10 posts, there is a "More answers" at the 10th post and you have to click on it.
Sometimes, this link is not displayed, because the software ST uses here is crap, and you have to reload the thread.
JW
2022-07-06 05:07 AM
Thanks for the support! I have solved the problem! The code is correct, the payment is in order.