2009-04-09 08:15 PM
systick is not working when SPI interruption enabled
2011-05-17 04:09 AM
Hello,
On some strange reason I can't make SysTick and SPI interruption work together. As soon as I enable SPI interrupts I am not able to catch systick iterrupts (I checking by setting a break point in the systick interrupt handler). I am new to STM32 so I am definitely doing something wrong, but I can't find what. Sorry for long listings, Any help would very much appreciated. Thanks. SPI initialization:Code:
<BR>void spi_init() <BR>{ <BR> SPI_InitTypeDef SPI_InitStructure; <BR> SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; <BR> SPI_InitStructure.SPI_Mode = SPI_Mode_Master; <BR> SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; <BR> SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; <BR> SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; <BR> SPI_InitStructure.SPI_NSS = PI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; <BR> SPI_InitStructure.SPI_CRCPolynomial = 0; <BR> SPI_Init(SPI1, &SPI_InitStructure); <BR> <BR> /* Enable SPI1 */ <BR> SPI_Cmd(SPI1, ENABLE); <BR> <BR> SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE); <BR> SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE); <BR>} <BR>
Systick Timer initializationCode:
<BR>void Timer_Config() <BR>{ <BR> /* Set 9Mhz clock source */ <BR> SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); <BR> <BR> SysTick_SetReload(COUNTER_DIVIDER); <BR> <BR> /* Enable SysTick interrupt */ <BR> SysTick_ITConfig(ENABLE); <BR> <BR> /* Enable SysTick counter */ <BR> SysTick_CounterCmd(SysTick_Counter_Enable); <BR>} <BR>
Interrupts configurationCode:
<BR>void USB_Interrupts_Config(void) <BR>{ <BR> NVIC_InitTypeDef NVIC_InitStructure; <BR> <BR> NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); <BR> <BR> NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQChannel; <BR> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; <BR> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; <BR> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; <BR> NVIC_Init(&NVIC_InitStructure); <BR> <BR> NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 0, 1); <BR> <BR> NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQChannel; <BR> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 11; <BR> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; <BR> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; <BR> NVIC_Init(&NVIC_InitStructure); <BR> <BR> NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN_RX0_IRQChannel; <BR> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; <BR> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; <BR> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; <BR> NVIC_Init(&NVIC_InitStructure); <BR>} <BR>
[ This message was edited by: fat031cc on 10-04-2009 08:49 ]