2020-04-07 02:09 AM
Environment
I'm attempting to generate PWM signals with DMA in normal mode, but doesn't work. I'm stack in this issue for a week. I'm very happy if you give me any advice. Thank you in advance.
other info
I attached files.
This is a whole project
2020-04-07 02:40 AM
Check AN4776 Application note General-purpose timer cookbook for a working solution.
2020-04-07 04:26 AM
Hello,
You can find the example under the STM32Cube directory:
STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Projects\NUCLEO-L476RG\Examples\TIM\TIM_DMA\src.
This example can help you to solve your problem. You can compare your files with the mentioned example.
Note: In your file STM32L4xx_hal_msp.c,
you put: hdma_tim1_ch3.Init.Direction = DMA_PERIPH_TO_MEMORY;
But, you must put: hdma_tim1_ch3.Init.Direction =DMA_MEMORY_TO_PERIPH;
Please find attached the example allowing to generate PWM signals using DMA on two channels.
Regards
2020-04-07 04:28 AM
2020-04-07 06:31 PM
Hi, ICHOR.1
Thank you for your reply.
>You can find the example under the STM32Cube directory:
I've already tried the example code.
The code itself works out, but when I copy and paste files below to my project and run them, no signal is generated.
-------------
main.c
stm32l4xx_hal_msp.c
stm32l4xx_it.c
system_stm32l4xx.c
main.h
stm32l4xx_hal_conf.h
stm32l4xx_it.h
-------------
At that time, I commented out
- #include "stm32l4xx_nucleo.h" in main.h
- two lines for LED in main.c
because they causes errors.
>But, you must put: hdma_tim1_ch3.Init.Direction =DMA_MEMORY_TO_PERIPH;
I tried this but no change
I also copied and pasted your files to my project, but no change.
2020-04-07 07:57 PM
This is a whole project
2020-04-07 10:47 PM
Hi, berendi,
I would like to code using HAL.
2020-04-07 11:09 PM
HAL functions are rather poorly documented. It is often not clear what exactly a function or parameter is supposed to do.
You can of course try to solve it using HAL. You might get lucky, and find a working solution. I have found that reading the reference manual and using the registers directly is a more reliable way to get results in a finite amount of time.