cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx TIM7 Stopping

Posted on January 04, 2013 at 09:13

I want to use TIM6 and TIM7 together .

TIM6- Update Event - 2MHz  priority 0x10

TIM7- Update Event - 1MHz priority 0x00

when I closed TIM6 , TIM7 is running normally and toggling LED from PD14 but when I enabled TIM6's CEN bit TIM7 is stopping.

I'm sending the project. Thanks.
4 REPLIES 4
Posted on January 04, 2013 at 10:46

Please use descriptive name for your post - this has nothing to do with CCD.

Your problem is not TIM7 stopping, but the TIM6 ISR effectively clearing the PD14 pin which you use as indicator:

#define     oscGozlem                    (~GPIOD->ODR & 0x0008000)

void TIM6_DAC_IRQHandler(void)

{

    TIM6->SR &= TIM67_SR_MASK;

    GPIOD->ODR = oscGozlem;

[...]

You should use the BSRR register to set/clear individual GPIO bits.

JW

Posted on January 04, 2013 at 13:47

I've removed the macro and write in to the TIM6 IRQ handler ;

if ((GPIOD->ODR & 0x00008000) != (uint32_t)Bit_RESET)

{

GPIOD->BSRRL &= 0x7FFF;

GPIOD->BSRRH |= 0x8000;

}

else

{

GPIOD->BSRRH &= 0x7FFF;

GPIOD->BSRRL |= 0x8000;

}

and it's normally running now. Thank you JW.

There's a one issue now

I've tried to write these codes like a macro but it did not work ;

#define xxx ((GPIOD->ODR & 0x00008000) != (uint32_t)Bit_RESET) ? GPIOD->BSRRL &= 0x7FFF, GPIOD->BSRRH |= 0x8000 : GPIOD->BSRRH &= 0x7FFF, GPIOD->BSRRL |= 0x8000

Must I use just one code at the each conditions?

Posted on January 04, 2013 at 14:06

Surely the following would suffice?

if ((GPIOD->ODR & 0x00008000) != (uint32_t)Bit_RESET)

GPIOD->BSRRH = 0x8000;

else

GPIOD->BSRRL = 0x8000;

The write is design to set or clear specific bit(s), and is self masking, and thus not requiring a RMW, or complexity of your solution.

Maybe your macro should use a compound statement?

Also 1 & 2 MHz interrupt rates are stupidly high, use the timers in PWM or Toggle mode to generate high rate signals like this.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 04, 2013 at 23:17

Thanks for your advice clive1. I was started to thinking why the outputs are really stupitly high.