AnsweredAssumed Answered

SPI read inside TIM1 Update interrupt freeze

Question asked by anton.bogdan on Jan 22, 2018
Latest reply on Jan 31, 2018 by mouser

Hello all,

 

i have a aplication for a 3 phase motor, where i have 3 sensors read via SPI.

 

The microcontroler is a stm32F427 device

 

I am using timer1 for 6 pwm output, and the timer in countin mode   TIM_CounterMode_CenterAligned3    

 

So i am expecting a update event on the middle of the "ON period", till here everything works as expected.

 

 

I am using two main IRQ handlers,   one is timer2 where i  setup the timer1 outputs ( acording to HALL inputs on TIM2 and XORED)

 

And the other IRQ handler is TIM1 Update handler

 

 

 

 

 

 

My problem is that if i have SPI read inside the timer1 update handler, the microcontroler wont start the motor.

 

 

If i dont have spi code,  everything works.  Why?   

What is even courious, that i have SPI activiti which seems ok ( seen with a logic analyzer)... I

 

void TIM1_UP_TIM10_IRQHandler(void){

if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);

 

// Read Phase current U
GPIOE->BSRRH = GPIO_Pin_10; // set Chip select 3 Low
SPI1->DR = 0x00;/// write dummy data to trigger clock
while( !(SPI1->SR & SPI_I2S_FLAG_TXE) ); // wait until transmit complete
while( !(SPI1->SR & SPI_I2S_FLAG_RXNE) ); // wait until receive complete
while( SPI1->SR & SPI_I2S_FLAG_BSY ); // wait until SPI is not busy anymore
current[0] =SPI1->DR; // return received data from SPI data register
GPIOE->BSRRL = GPIO_Pin_10; // set Chip select 3High
 

    }
}

Outcomes