我把ucos的OS_TICKS_PER_SEC 设为1000 就是1秒1000个节拍.. 我在用超声波模块的时候,开启一个外中断 程序运行一小时间就进入了硬件中断.我在ucos上是有跑其它任务的,任务还是比较多的. 但是只要关了这个中断(外中断) ucos就能正常跑了. 这东西折腾我好几天了,我都快崩溃了.有没谁能帮忙解答下不? 以下是我的程序: 1,中断 void EXTI1_IRQHandler(void) { OS_CPU_SR cpu_sr; OS_ENTER_CRITICAL(); OSIntNesting++; OS_EXIT_CRITICAL(); if(EXTI_GetITStatus(EXTI_Line1) != RESET) { //有检测到信号 但是不是反射回来的信号还不能确定, 一般Time大于20应该是接收到信号 EXTI_Cmd(DISABLE); CSB_Time=TIM_GetCounter(TIM5); OS_EXIT_CRITICAL(); } OSIntExit(); } 中断的配置: void CSB_NVIC(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructure); } void CSB_EXTI(void) { EXTI_InitTypeDef EXTI_InitStructure; EXTI_InitStructure.EXTI_Line=EXTI_Line1; EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd=ENABLE;//先关闭外中断,等发送完声波再延迟一小时间再开启 EXTI_Init(&EXTI_InitStructure); } |
RE:ucos移植到STM32 外中断开启后很快进硬件中断