2018-06-20 09:27 AM
In the stem32f10x_dma.c the DMA_DeInit function has the following lines:
/* Disable the selected DMAy Channelx */
DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN); /* Reset DMAy Channelx control register */ DMAy_Channelx->CCR = 0;I can't quite figure out why there is a double write to the CCR register. After digging through the documents i did find a note:
Note: If a DMA channel is disabled, the DMA registers are not reset. The DMA channel registers
(DMA_CCRx, DMA_CPARx and DMA_CMARx) retain the initial values programmed during
the channel configuration phase.
However this note makes the code make even less sense, because the /*Reset DMAy_Channelx control register*/ action would not do anything? So is one of these lines
unnecessary? what is the actual purpose of the double write to CCR?
2018-06-20 04:01 PM
Perhaps it avoids some hazards by cleanly stopping the DMA unit, before changing all the settings? It is not a 'memory' location, as much as it is the control to some pipelined state machine.
The automotive equivalent to being at a complete stop before dragging the shifter all the way across to PARK.
2018-06-21 03:42 PM
Well thanks for the reply, however I'm looking for a bit more than speculation. Disabling the channel would prevent other information from being edited according to the note, Its on pg 278 of the
. But this may be useful if the theory is testable, I dont know if you could tell the difference given that the time to write to the register takes almost no time, it would give the DMA very little time to adjust to any changes before being disabled. It might also be good to know who/where to find answers on this library if you have any information, that would be great. Thanks!2018-06-21 06:17 PM
The SPL is deprecated, the F1 design is a decade old, the FAE servicing your account would probably the best point person, the IC Design Engineers don't frequent the forum, the ones on the F1 design likely 5-6 projects beyond that. There is a separate 'Online Support Ticket' system that might be worth a try.
The back-to-back write to the AHB/APB are of the order of 4-cycles. Doing things like TIM2->CNT += 8; won't advance the counter. And TIM1->SR &= ~1; induces hazards.