我想起用外部中断0和外部中断6。经过我的设置,程序总是在外部中断6的服务程序里运行。PC6的输入电平一直是低电平。即使我将PC6相关的中断语句屏蔽掉。程序就在EXIT0中断服务程序里死循环。下面是我的设置: I/O口设置: void CC113L_SPI_GPIOInit(void) { GPIO_Init(GPIOD, GPIO_Pin_0, GPIO_Mode_In_FL_IT); //GDO0 外部中断0 GPIO_Init(GPIOB, GPIO_Pin_5, GPIO_Mode_Out_PP_Low_Slow); //SCK GPIO_Init(GPIOA, GPIO_Pin_3, GPIO_Mode_Out_PP_Low_Slow); //MOSI GPIO_Init(GPIOA, GPIO_Pin_2, GPIO_Mode_In_PU_No_IT); //MISO GPIO_Init(GPIOC, GPIO_Pin_4, GPIO_Mode_Out_PP_Low_Slow); //CSN GPIO_Init(GPIOC, GPIO_Pin_5, GPIO_Mode_In_FL_No_IT); } void USART_GpioInit(void) { GPIO_Init(GPIOC, GPIO_Pin_6, GPIO_Mode_In_FL_IT); //外部中断6 GPIO_Init(GPIOC, GPIO_Pin_0, GPIO_Mode_Out_PP_High_Slow); //PC0 } void EXIT_Init(void) { EXTI_DeInit(); EXTI_SetPinSensitivity(GPIO_Pin_0,EXTI_Trigger_Rising); EXTI_SetPinSensitivity(GPIO_Pin_6,EXTI_Trigger_Falling); ITC_SetSoftwarePriority(EXTI6_IRQn,ITC_PriorityLevel_3); ITC_SetSoftwarePriority(EXTI0_IRQn,ITC_PriorityLevel_2); EXTI_ClearITPendingBit(EXTI_IT_Pin6); EXTI_ClearITPendingBit(EXTI_IT_Pin0); enableInterrupts(); } 下面是Vector.c里的设置: #include "stm8l15x_it.h" typedef void @far (*interrupt_handler_t)(void); struct interrupt_vector { unsigned char interrupt_instruction; interrupt_handler_t interrupt_handler; }; @far @interrupt void NonHandledInterrupt (void) { /* in order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction */ return; } extern void _stext(); /* startup routine */ extern void EXTI0_IRQHandler(void); extern void EXTI6_IRQHandler(void); struct interrupt_vector const _vectab[] = { {0x82, (interrupt_handler_t)_stext}, /* reset */ {0x82, NonHandledInterrupt}, /* trap */ {0x82, NonHandledInterrupt}, /* irq0 */ {0x82, NonHandledInterrupt}, /* irq1 */ {0x82, NonHandledInterrupt}, /* irq2 */ {0x82, NonHandledInterrupt}, /* irq3 */ {0x82, NonHandledInterrupt}, /* irq4 */ {0x82, NonHandledInterrupt}, /* irq5 */ {0x82, NonHandledInterrupt}, /* irq6 */ {0x82, NonHandledInterrupt}, /* irq7 */ {0x82, EXTI0_IRQHandler}, /* irq8 */ {0x82, NonHandledInterrupt}, /* irq9 */ {0x82, NonHandledInterrupt}, /* irq10 */ {0x82, NonHandledInterrupt}, /* irq11 */ {0x82, NonHandledInterrupt}, /* irq12 */ {0x82, NonHandledInterrupt}, /* irq13 */ {0x82, EXTI6_IRQHandler}, /* irq14 */ {0x82, NonHandledInterrupt}, /* irq15 */ {0x82, NonHandledInterrupt}, /* irq16 */ {0x82, NonHandledInterrupt}, /* irq17 */ {0x82, NonHandledInterrupt}, /* irq18 */ {0x82, NonHandledInterrupt}, /* irq19 */ {0x82, NonHandledInterrupt}, /* irq20 */ {0x82, NonHandledInterrupt}, /* irq21 */ {0x82, NonHandledInterrupt}, /* irq22 */ {0x82, NonHandledInterrupt}, /* irq23 */ {0x82, NonHandledInterrupt}, /* irq24 */ {0x82, NonHandledInterrupt}, /* irq25 */ {0x82, NonHandledInterrupt}, /* irq26 */ {0x82, NonHandledInterrupt}, /* irq27 */ {0x82, NonHandledInterrupt}, /* irq28 */ {0x82, NonHandledInterrupt}, /* irq29 */ }; 外部中断6的服务程序(在it.c里面): @far @interrupt void EXTI6_IRQHandler(void) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ EXTI_ClearITPendingBit(EXTI_IT_Pin6); time_ok = 1; sleep_ok = 1; } 外部中断0 的服务程序: @far @interrupt void EXTI0_IRQHandler(void) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ INT8U length = 0x05; EXTI_ClearITPendingBit(EXTI_IT_Pin0); if(CC113L_halRfReceivePacket(RxBuf,&length) == 1) { Rx_ok = 1; } } |
从零开始操作STM8寄存器(风驰iCreate奉献)
【中文资料】初学STM8库函数的中文帮助软件
绝对经典的中文STM8学习手册,淘宝上学习板资料,友情大放送!
【原创教程】风驰iCreate独家开源STM8 27个例程和10多万字的pdf教程
STM8的LCD1602 4线驱动,为什么不工作
【精华资料】由零开始开发STM8
STM8S 的触摸库是如何在主程序中查询键的呢、
【精华资料】STM8的C语言编程1-14讲完整版
【精品教程】STM8系列单片机入门教程系列
STM8 第一次进中断不准【悬赏问答】
RE:STM8L的外部中断死循环
回复:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
回复:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
回复:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
RE:STM8L的外部中断死循环
回复:STM8L的外部中断死循环
RE:STM8L的外部中断死循环