2023-04-02 01:46 PM
I'm new to STM parts and toolchain and I need to send input capture values from TIM1 to the DAC output via DMA. Cube doesn't support peripheral to peripheral DMA, but its been suggested I can accomplish it with a peripheral to memory DMA transfer, triggered by TIM1\CH4 if I supply the address of the DHR12RD register as a destination address. The user guide says this register is not memory mapped, but I can see what address is from the generated code. What happens if I attempt this? Is there another way to do it?
Also, the DAC is 12 bit and TIM1 is 16 bit, so I'm hoping the top four bits are simply ignored. Since the above method is non-standard, I'm not sure if this could make things not work. Under normal functioning, the capture registers will not record values above 4096, so overflows are not anticipated.
Solved! Go to Solution.
2024-06-21 01:21 PM
CubeIDE only narrowly supports DMA. By adding post-config steps to the code to change CPAR and CMAR registers, the desired transfer is easy to accomplish.
2023-04-02 03:10 PM
Which STM32?
> The user guide says this register is not memory mapped
What user guide say this?
> its been suggested
By whom?
> I can accomplish it with a peripheral to memory DMA transfer, triggered by TIM1\CH4
Probably yes, but why TIM1/CH4?
Have you tried?
JW
2023-04-02 03:18 PM
Depending on the part you'd use a DMA to move from the TIMx->CCRx that's triggered by the TIMx Update or CCx, and write the content to the DAC
This might need to be a DMA unit capable of memory-to-memory.
Experiment
2023-04-02 04:05 PM
STM32L43
Manual
22.4.3 Mentions the memory mapping
TIM1_CH4_TRIG/COM is the only available trigger shown Cube. Using should work just fine.
Sometime doing weird stuff like this can brick the unit and I lack means of debug, so I'm asking in advance.
2023-04-02 04:07 PM
Memory to memory is also an option if you can just read and write from the relevant registers by the memory addresses...but I need to establish that.
2023-04-05 02:34 PM
I've worked through some other problems and I have the unit running PWM that feeds ETR1 and TIM1\CH4. Without using DMA I wrote TIM1\CCR4 to DAC1 and I was able to observe correcty output. I tried to switch the DMA trick above and it didn't work. There may be different ways to do it, but I lack observability.
I used this line to start DMA:
HAL_DAC_Start_DMA(&hdac1,DAC_CHANNEL1,(uint32_t *) 0x40012C40U,1,DAC_ALIGN_12_B);
TIM1 base address is 0x40012C00
CCR4 off set is 0x40.
Any ideas on what to try are appreciated.
2024-06-21 01:21 PM
CubeIDE only narrowly supports DMA. By adding post-config steps to the code to change CPAR and CMAR registers, the desired transfer is easy to accomplish.