cancel
Showing results for 
Search instead for 
Did you mean: 

SPI and Timer incompatibility?

berthier
Associate
Posted on June 16, 2014 at 11:28

Hello!

I'm actually trying to use TIM2 interrupt and use SPI in the same time. But when I initialise the SPI peripheral, it doesn't work : there is no timer interrupt any more.

You can see above the main function and the useful interrupt functions

int main(void)

{

    

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

                          RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |

                          RCC_APB2Periph_GPIOE, ENABLE);

    

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;

   GPIO_Init(GPIOA, &GPIO_InitStructure);

   GPIO_Init(GPIOB, &GPIO_InitStructure);

   GPIO_Init(GPIOC, &GPIO_InitStructure);

   GPIO_Init(GPIOD, &GPIO_InitStructure);

   GPIO_Init(GPIOE, &GPIO_InitStructure);

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

                          RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |

                          RCC_APB2Periph_GPIOE, DISABLE);

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    GPIO_InitTypeDef gpioinit;

    gpioinit.GPIO_Mode=GPIO_Mode_IPD;

    gpioinit.GPIO_Speed=GPIO_Speed_50MHz;

    gpioinit.GPIO_Pin=GPIO_Pin_12;

    GPIO_Init(GPIOA, &gpioinit);

    if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_12) != 0)

    {

        while (1)

        {

        }

    }

    /*power on RFM12 module*/ //The SPI peripheral

   RFM12_poweron();

   /*initialize SPI1 peripheral to communicate with RFM12*/

   hlperiph_SPI1master_init();

    

   /*initializes RFM12 with correct configuration*/

   RFM12_init();

   hlperiph_led_init();

   hlperiph_EXTI_PA0_init();

     uint8_t tx_start[] = ''\r\nStarting main'';  //Send a message throught the SPI peripheral

     RFM12_TxData(tx_start, 15);

    

 

        

      // SysTick end of count event each 1ms

  RCC_GetClocksFreq(&RCC_Clocks);

  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);

    

       hlperiph_timer2_init();

      // RFM12_init();

       transmit();

       RFM12_poweroff();

            

            

   /* Infinite loop */

  while (1)

  { }

}

void TIM2_IRQHandler(void)

{

    if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)

    {

      TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

        

        RFM12_init();

      uint8_t tx_TIM3[] = ''TIM2'';

      RFM12_TxData(tx_TIM3, 4);

        

    }

}

Thank you very much,

H�lo�se

#stm32
2 REPLIES 2
Posted on June 16, 2014 at 14:04

Which STM32? On what board?

Code breaks JTAG/SWD connectivity, so presumably you haven't done any debugging.

Code tries to init/send SPI data in an interrupt, this will take a lot of time.

Fails to show initialization of TIM, SPI and related GPIOs which would be particularly salient given the posting.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
berthier
Associate
Posted on June 17, 2014 at 09:22

STM32F100C4, program through a nucleo board.