2013-01-04 12:13 AM
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.2013-01-04 01:46 AM
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. JW2013-01-04 04:47 AM
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?2013-01-04 05:06 AM
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.2013-01-04 02:17 PM
Thanks for your advice clive1. I was started to thinking why the outputs are really stupitly high.