关于在RTX5中使用SVC中断
在RTX5工程中使用的SVC中断一直不能正常运行,大家有没有模板,想参考一下,谢谢了!下面是官方的说明:
[*]Add the SVC User Table file svc_user.c to your project folder and include it into your project. This file is available as a user code template.
[*]Write a function implementation. Example:uint32_t svc_atomic_inc32 (uint32_t *mem) {
// A protected function to increment a counter.
uint32_t val;
__disable_irq();
val= *mem;
(*mem) = val + 1U;
__enable_irq();
return (val);
}
[*]Add the function to the SVC function table in the svc_user.c module:void * const osRtxUserSVC = {
(void *)USER_SVC_COUNT,
(void *)svc_atomic_inc32,
};
[*]Increment the number of user SVC functions:#define USER_SVC_COUNT1 // Number of user SVC functions
[*]Declare a function wrapper to be called by the user to execute the SVC call.
Code Example (Arm Compiler 6)__STATIC_FORCEINLINE uint32_t atomic_inc32 (uint32_t *mem) {
register uint32_t val;
__ASM volatile (
"svc 1" : "=l" (val) : "l" (mem) : "cc", "memory"
);
return (val);
}
Code Example (Arm Compiler 5 using __svc(x) attribute)uint32_t atomic_inc32 (uint32_t *mem) __svc(1);
楼主位的确定是可以的,直接复制粘贴即可,昨天你不是看了么,你没有实际测试下?
RTX5中自定义使用SVC中断方法
http://www.armbbs.cn/forum.php?m ... id=95810&fromuid=58
(出处: 硬汉嵌入式论坛)
eric2013 发表于 2020-4-14 11:23
楼主位的确定是可以的,直接复制粘贴即可,昨天你不是看了么,你没有实际测试下?
RTX5中自定义使用SVC ...
这是我测试用svc_user.c中的程序,一直进不到中断里边去
#include "cmsis_os2.h"
#include "Measure.h"
#include "led.h"
extern osEventFlagsId_t Measureflag_id;
extern osStatus_t status1,statys2;
extern void LED_thread(void *argument);
void svc_TIM3_Int_Init(u16 arr,u16 psc)
{
TIM_TimeBaseInitTypeDefTIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //时钟使能
//定时器TIM3初始化
TIM_TimeBaseStructure.TIM_Period = arr; //设置在下一个更新事件装入活动的自动重装载寄存器周期的值
TIM_TimeBaseStructure.TIM_Prescaler =psc; //设置用来作为TIMx时钟频率除数的预分频值
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置时钟分割:TDTS = Tck_tim
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//TIM向上计数模式
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx的时间基数单位
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); //使能指定的TIM3中断,允许更新中断
//中断优先级NVIC设置
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;//TIM3中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//先占优先级0级
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//从优先级3级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道被使能
NVIC_Init(&NVIC_InitStructure);//初始化NVIC寄存器
TIM_Cmd(TIM3, ENABLE);//使能TIMx
}
#define USER_SVC_COUNT1 // Number of user SVC functions
extern void * const osRtxUserSVC;
void * const osRtxUserSVC = {
(void *)USER_SVC_COUNT,
(void *)svc_TIM3_Int_Init,
//(void *)user_function1,
// ...
};
void TIM3_Int_Init(u16 arr,u16 psc) __svc(1);
void TIM3_IRQHandler(void)
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)//检查TIM3更新中断发生与否
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);//清除TIMx更新中断标志
status1 = osEventFlagsSet (Measureflag_id,0x01);
osThreadNew(LED_thread,NULL,NULL);
}
} sldx 发表于 2020-4-15 13:06
这是我测试用svc_user.c中的程序,一直进不到中断里边去
#include "cmsis_os2.h"
#include "Measure.h" ...
你楼主位代码缺东西,没有关联起来。
atomic_inc32和svc_atomic_inc32 eric2013 发表于 2020-4-15 18:17
你楼主位代码缺东西,没有关联起来。
atomic_inc32和svc_atomic_inc32
硬汉哥,我都是根据官方教程来写的,不太清楚怎么关联起来,麻烦解释一下,感谢 sldx 发表于 2020-4-15 22:03
硬汉哥,我都是根据官方教程来写的,不太清楚怎么关联起来,麻烦解释一下,感谢
分享RTX5的自定义SVC软中断两种实现方法
http://www.armbbs.cn/forum.php?mod=viewthread&tid=97322
页:
[1]