2019-09-15 10:28 AM
My timer config:
RCC_APB1ENR = RCC_APB1ENR_TIM3EN;
TIM3_CR1 = (uint32_t)(TIM_CR1_CKD_CK_INT | TIM_CR1_CMS_CENTER_3);
TIM3_CR1 &= ~TIM_CR1_UDIS;
TIM3_CR2 &= ~TIM_CR2_CCDS;
TIM3_ARR = (uint32_t)10000;
TIM3_DIER = (uint32_t)(TIM_DIER_CC1DE | TIM_DIER_CC1IE);
PWM_BORDER = (uint32_t)7000;
So, timer interrupt is working well only when I null CCR event in the interupt.
But transaction interrupt arises at random moments of time. While transacion must takes few SysClk's. May be I have wrong timer config of timer or wrong DMA channel?
DMA config:
RCC_AHBENR |= RCC_AHBENR_DMA1EN;
DMA1_CPAR4 = (uint32_t) &GPIOF_BSRR;
DMA1_CMAR4 = (uint32_t) &clockSeq;
DMA1_CNDTR4 = (uint32_t) 4;
uint32_t ccr = DMA_CCR_MINC | DMA_CCR_MSIZE_16BIT | DMA_CCR_PSIZE_16BIT;
ccr |= DMA_CCR_PL_VERY_HIGH | DMA_CCR_DIR | DMA_CCR_CIRC;
ccr |= DMA_CCR_HTIE | DMA_CCR_TCIE | DMA_CCR_TEIE;
DMA1_CCR4 = ccr;
As said earlier, I have interrupt at wrong moments of CLK
void dma1_channel4_7_dma2_channel3_5_isr()
{
// TIM3_SR &= ~TIM_SR_CC1IF;
static int cnt = 0;
timDump[cnt++] = TIM3_CNT;
if(cnt == 50) cnt = 0;
}
timDump = 3817, 3913, 4009, 4105, 4201 ...
stm32f030f4p6 MCU.
Solved! Go to Solution.
2019-09-15 10:34 AM
BSRR should be 32-bit wide
ARR = N-1 for Divide by N
CNT will be zero at update event, and thus DMA HT/TC IRQs
TIM3_UP is channel 3 on the DMA, not 4
2019-09-15 10:34 AM
BSRR should be 32-bit wide
ARR = N-1 for Divide by N
CNT will be zero at update event, and thus DMA HT/TC IRQs
TIM3_UP is channel 3 on the DMA, not 4
2019-09-15 10:43 AM
Thank you, but I want to clock on compare event, not update
2019-09-15 12:27 PM
For Channel 4 (TIM3_CH1), you'd need to configure TIM3->CCR1 and enable it
2019-09-15 12:30 PM
Read out and check/post content of relevant TIM and DMA registers.
JW
2019-09-15 09:50 PM
checked
2019-09-15 10:17 PM
And did you find the problem?
Do you check and clear the DMA status flag which causes the DMA ISR to be invoked?
JW
2019-09-15 11:35 PM
checked