Skip to main content
Kasapoglu.Orkun
Senior
January 4, 2013
Question

STM32F4xx TIM7 Stopping

  • January 4, 2013
  • 4 replies
  • 725 views
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.
    This topic has been closed for replies.

    4 replies

    waclawek.jan
    Super User
    January 4, 2013
    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

    Kasapoglu.Orkun
    Senior
    January 4, 2013
    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?

    Tesla DeLorean
    Guru
    January 4, 2013
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Kasapoglu.Orkun
    Senior
    January 4, 2013
    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.