Using SPI1 disables TIMER1 compare interupt

Post here first, or if you can't find a relevant section!
Post Reply
abhisheksafui
Posts: 3
Joined: Sun May 14, 2017 4:43 pm

Using SPI1 disables TIMER1 compare interupt

Post by abhisheksafui » Sun May 14, 2017 4:49 pm

Is there any relation between timer 1 and spi 1. I was using timer 1 channel 1 compare match interrupt, but as sson as i enabled SPI 1, the timer interrupt never gets called. Just changing the timer number re enables the interrupt. How do I use both of them?

stevestrong
Posts: 1505
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Using SPI1 disables TIMER1 compare interupt

Post by stevestrong » Sun May 14, 2017 5:48 pm

Which pin do you use for SPI1 chip select ?
Because the PA8..PA11 pins are timer 1 related and they will be overwritten by pinMode().

User avatar
RogerClark
Posts: 6682
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Using SPI1 disables TIMER1 compare interupt

Post by RogerClark » Sun May 14, 2017 10:01 pm

We have an open issue with pinmode disabling other timers to turn off pwm.
But it doesnt seem to be necessary to turn off the timer ( I thought it was Timer 4 but I would need to double check)

If we comfirm that pinmode does not need to disable any timers, and chance to Core, Perhaps it would fix this.

rmdMoba
Posts: 16
Joined: Thu May 11, 2017 10:44 am

Re: Using SPI1 disables TIMER1 compare interupt

Post by rmdMoba » Mon May 15, 2017 8:45 am

Yes, I found this issue when using timer 4. But it's not limited to timer 4. If you set a non-pwm mode on any pwm capable pin, then the corresponding timerchannel is disabled. The timer_set_mode() function for this timer/channel ist called with parameter 'TIMER_DISABLED'. This clears the compareOutputEnable Bit of that channel and detaches the attached ISR's. The main problem is that the ISR's are detached.
My fix at the moment is, to not call the timer_set_mode() fuction when a non-pwm mode is set. This doesn't clear the compareOutputEnable Bit if it was set by a previous pwm mode. But that doesn't seem to matter, because the output pin is disconnected from the timer by the gpio configuration in non pwm modes. In my tests the fix worked so far when setting PWM - reset to OUTPUT - and set PWM again. But I will do some more tests with different port modes.
You can check if that fix solves your problem too by editing the ..../hardware\Arduino_STM32\STM32F1\cores\maple\stm32f1\wirish_digital_f1.cpp.
The fix is fairly simple, as you can see here

abhisheksafui
Posts: 3
Joined: Sun May 14, 2017 4:43 pm

Re: Using SPI1 disables TIMER1 compare interupt

Post by abhisheksafui » Mon May 15, 2017 5:06 pm

Yes that fixed the problem. But before that fix i found that shifting my pins to 7,6,4,3 and 2 also enabled all the timers. 4 and 3 are pwm pins why didn't they interfere any timer?

When I use pin 27 as output, timer 1 stops. How do I know which pins are related to which timer?
As someone said that pins 8-11 are associated with timer 1, then why pin 27 stops timer 1?

abhisheksafui
Posts: 3
Joined: Sun May 14, 2017 4:43 pm

Re: Using SPI1 disables TIMER1 compare interupt

Post by abhisheksafui » Mon May 15, 2017 5:50 pm

Ok thanks. I found out the pin map 24-27 maps to PORTA8-11.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests