Jump to content

    
Sign in to follow this  
Алексей ВМ

Обработка прерывания с более высоким приоритетом

Recommended Posts

Добрый день!

Чип stm32f405.

Имеется прерывание от DMA, приоритет 15. В этом прерывании запускается таймер, приоритет 0, далее обработчик прерывания DMA занимается своими делами ещё 5 мкс. Таймер выставлен на 3 мкс. Если я правильно понимаю, выполнения обработчика прерывания DMA должно прерваться при срабатывании таймера, однако этого не происходит. Что я делаю не так?

Инициализация

		NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
		NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
		NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
		NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
		NVIC_Init(&NVIC_InitStructure);	

		NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream5_IRQn;
		NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15;
		NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
		NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
		NVIC_Init(&NVIC_InitStructure);		

 

Обработчик DMA

 

void DMA2_Stream5_IRQHandler(void)
{
		uint8_t i,j = 0;
	
		if(DMA_GetITStatus(DMA2_Stream5, DMA_IT_TCIF5))
		{							
				DMA_ClearITPendingBit(DMA2_Stream5, DMA_IT_TCIF5);
			
				DMA_Cmd(DMA2_Stream5, DISABLE);
			
				TIM_Cmd(OUT_TIM, DISABLE);												
												
			
				TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
				TIM_SetCounter(TIM3, 0);	
				TIM_Cmd(TIM3, ENABLE);	

          
          		.......

 

Edited by Алексей ВМ

Share this post


Link to post
Share on other sites

Покажите вызов NVIC_SetPriorityGrouping, в частности - значение ее параметра.

 

 

К слову:

NOTE: Some third-party code libraries (e.g., the STM32 driver library) change the priority grouping configuration to non-standard. 
Therefore, it is highly recommended to explicitly re-set the priority grouping to the default 
  by calling the CMSIS function NVIC_SetPriorityGrouping(0U) after initializing such external libraries.

подробности

Share this post


Link to post
Share on other sites

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

 

4 бита для for preemption.

 

Функцию NVIC_SetPriorityGrouping() не вызываю, она же дублирует NVIC_PriorityGroupConfig() ?

 

Никаких сторонних либ не использую.

 

Edited by Алексей ВМ

Share this post


Link to post
Share on other sites
9 minutes ago, Алексей ВМ said:

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

4 бита для for preemption.

Тыц

 

Quote

Никаких сторонних либ не использую.

Уверены? ;)

 

9 minutes ago, Алексей ВМ said:

Функцию NVIC_SetPriorityGrouping() не вызываю, она же дублирует NVIC_PriorityGroupConfig() ?

Не знаю, в CMSIS нет NVIC_PriorityGroupConfig.

 

Share this post


Link to post
Share on other sites

Судя по таблице, в группе из 4 бит, NVIC_IRQChannelSubPriority должен быть равен 0.

The table below gives the allowed values of the pre-emption priority and subpriority according
 to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
  ============================================================================================================================
    NVIC_PriorityGroup   | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority  | Description
  ============================================================================================================================
   NVIC_PriorityGroup_0  |                0                  |            0-15             |   0 bits for pre-emption priority
                         |                                   |                             |   4 bits for subpriority
  ----------------------------------------------------------------------------------------------------------------------------
   NVIC_PriorityGroup_1  |                0-1                |            0-7              |   1 bits for pre-emption priority
                         |                                   |                             |   3 bits for subpriority
  ----------------------------------------------------------------------------------------------------------------------------    
   NVIC_PriorityGroup_2  |                0-3                |            0-3              |   2 bits for pre-emption priority
                         |                                   |                             |   2 bits for subpriority
  ----------------------------------------------------------------------------------------------------------------------------    
   NVIC_PriorityGroup_3  |                0-7                |            0-1              |   3 bits for pre-emption priority
                         |                                   |                             |   1 bits for subpriority
  ----------------------------------------------------------------------------------------------------------------------------    
   NVIC_PriorityGroup_4  |                0-15               |            0                |   4 bits for pre-emption priority
                         |                                   |                             |   0 bits for subpriority                       
  ============================================================================================================================

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this