关于#学习freertos使用时发生中断卡死#的问题,如何解决?

您所在的位置:网站首页 gpio如何使用 关于#学习freertos使用时发生中断卡死#的问题,如何解决?

关于#学习freertos使用时发生中断卡死#的问题,如何解决?

2023-04-11 15:44| 来源: 网络整理| 查看: 265

学习消息队列,调用freertos中断API函数时,出现了问题,调试追踪发现卡死在portASSERT_IF_INTERRUPT_PRIORITY_INVALID();这个宏,该如何解决呢。

其中主要是两个中断,配置如下:

HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(EXTI4_IRQn, 7, 0); // 对应是 CLK_CHECK_Pin 中断 HAL_NVIC_EnableIRQ(EXTI4_IRQn); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 10, 0); // 对应是 B2A_Pin 中断 HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

其中CLK_CHECK_Pin 中断发生时都能正常响应,就是当B2A_Pin 中断来临时出现卡死portASSERT_IF_INTERRUPT_PRIORITY_INVALID();这里,我的系统中实时性高,没法用printf来进行调试,只有通过逻辑分析仪和翻转LED来进行调试,已经尝试更改了B2A_Pin了的优先级设置为

HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); // 对应是 B2A_Pin 中断 HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

还是死机,暂时不晓得咋处理,现在唯一的解决方式在B2A_Pin 中断发生时不使用freertos相关API。来平台主要是想问一下有没有人碰到过类似的事情,如何解决的,同时是方便自己对freertos的理解

相关的业务的代码如下:

#include "business_task.h" #include "main.h" #include osThreadId businessTaskHandle; osMessageQId businessQueueHandle; // 业务任务的入口函数 void StartBusinessTask(void const * argument) { uint32_t data = 0; // 在这里编写任务的代码 while (1) { // 从消息队列中获取数据 osEvent event = osMessageGet(businessQueueHandle, osWaitForever); data = event.value.v; // 处理数据并进行相应的操作 if (data == CLK_CHECK_Pin) { do_something(); // 这里需要很长时间来进行处理 } else if(data == B2A_Pin) { HAL_GPIO_TogglePin(LED2_GPIO_Port,LED2_Pin); } } } // void SetBusinessQueueHandle(osMessageQId queue_id) // { // // 将消息队列句柄保存到全局变量中 // businessQueueHandle = queue_id; // } // 初始化业务任务 void InitBusinessTask(void) { osThreadDef(businessTask, StartBusinessTask, osPriorityRealtime, 0, 128); businessTaskHandle = osThreadCreate(osThread(businessTask), NULL); osMessageQDef(businessQueue, 16, uint32_t); // 将队列的最大容量设置为 16 businessQueueHandle = osMessageCreate(osMessageQ(businessQueue), NULL); // 将业务任务的消息队列句柄传递给中断处理函数 // SetBusinessQueueHandle(businessQueueHandle); } // 向业务任务发送数据 bool SendDataToBusinessTask(uint32_t data) { if (osMessagePut(businessQueueHandle, data, 0) != osOK) { return false; } return true; } void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == CLK_CHECK_Pin) { SendDataToBusinessTask(CLK_CHECK_Pin); } else if (GPIO_Pin == B2A_Pin) { // HAL_GPIO_TogglePin(LED2_GPIO_Port,LED2_Pin); SendDataToBusinessTask(B2A_Pin); } }

FreeRTOSConfig.h的内容如下:

/* USER CODE BEGIN Header */ /* * FreeRTOS Kernel V10.0.1 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * http://www.FreeRTOS.org * http://aws.amazon.com/freertos * * 1 tab == 4 spaces! */ /* USER CODE END Header */ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H /*----------------------------------------------------------- * Application specific definitions. * * These definitions should be adjusted for your particular hardware and * application requirements. * * These parameters and more are described within the 'configuration' section of the * FreeRTOS API documentation available on the FreeRTOS.org web site. * * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* Section where include file can be added */ /* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) #include extern uint32_t SystemCoreClock; #endif #define configUSE_PREEMPTION 1 #define configSUPPORT_STATIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configTOTAL_HEAP_SIZE ((size_t)6144) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 0 #define INCLUDE_vTaskDelay 1 #define INCLUDE_xTaskGetSchedulerState 1 /* Cortex-M specific definitions. */ #ifdef __NVIC_PRIO_BITS /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ #define configPRIO_BITS __NVIC_PRIO_BITS #else #define configPRIO_BITS 4 #endif /* The lowest interrupt priority that can be used in a call to a "set priority" function. */ #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 /* The highest interrupt priority that can be used by any interrupt service routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values. */ #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 /* Interrupt priorities used by the kernel port layer itself. These are generic to all Cortex-M ports, and do not rely on any particular library functions. */ #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3