|
从本站下载的UcOS_for_m128应用于M64,在ICCAVR下编译、AVR Studio411下调试,运行正常
修改如下:
1、在vector.s中增加外部中断0相关,如下所示(注:后面三行是原来有的,用于ucos系统)
.area INT0ISR_Vector(abs)
.org 1*4
JMP _OSInt0ISR
.area OSTickISR_Vector(abs)
.org 16*4
JMP _OSTickISR
2、在os_cpu_a.s中增加外部中断0服务子程序
_OSInt0ISR::
cli
PUSH_ALL ; Save all registers and status register
IN R16,SREG ; Save the SREG but with interrupts enabled
SBR R16,BIT07
ST -Y,R16
PUSH_SP ; Save the task's hardware stack pointer onto task's stack
LDS R16,_OSIntNesting ; Notify uC/OS-II of ISR
INC R16 ;
STS _OSIntNesting,R16 ;
CPI R16,1 ; if (OSIntNesting == 1) {
BRNE _OSInt0ISR_1
LDS R30,_OSTCBCur ; OSTCBCur->OSTCBStkPtr = Y
LDS R31,_OSTCBCur+1
ST Z+,R28
ST Z+,R29 ; }
_OSInt0ISR_1:
CALL _OSInt0ISR_Handler ; Handle the INT0 ISR
CALL _OSIntExit ; Notify uC/OS-II about end of ISR
POP_SP ; Restore the hardware stack pointer from task's stack
POP_SREG ; Restore the SREG register
POP_ALL ; Restore all registers
RET ; Note: RET instead of RETI
3、在app.c中,增加外部中断0初始化程序
void OSINT0ISR_Init(void)
{
EIMSK = 0x00; // 禁止外部中断
EICRA = 0x00; //extended ext ints // 低电平产生中断
EICRB = 0x00; //extended ext ints // 低电平产生中断
EIMSK = 0x01; // 使能外部中断0
}
和外部中断0服务程序
void OSInt0ISR_Handler(void)
{
led_ctl(1, LED_RESERVE); // 一个led灯状态取反
}
任务0程序
static void AppTaskStart (void *p_arg)
{
INT8U key = 0;
INT8U err;
p_arg = p_arg; /* Prevent compiler warnings */
OSTickISR_Init(); /* Initialize the ticker */
OSINT0ISR_Init();
led_init();
// AppTaskCreate();
while (TRUE) /* Task body, always written as an infinite loop. */
{
led_ctl(14, LED_RESERVE);
OSTimeDly(OS_TICKS_PER_SEC / 10);
}
}
如果在外部中断0服务程序中加断点全速运行,则每次按键都可以正常进入中断服务程序,系统也运行正常;如果不加断点全速运行,则若干次按键正常之后,系统就跑飞了,总是在idle中运行,跑不到任务中了,请问DX又遇到这种情况的吗? |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|