最近在学习kinetis K22芯片,移植入MQX Lite系统,发现在建一个task,一个外设GPIO口设置为外部中断。
1、外部输入中断信号使得产生中断的频率为1KHz.中断服务程序中,只有一条打印语句printf("into GPIO interrupt!\r\n");
2、任务task的优先级设置为2。外部GPIO中断优先级设置为8。
3、系统时钟滴答SysTick周期设置为5ms,中断优先级默认为8。
外部中断服务程序函数:
void ExtInt_OnInterrupt(void)
{
printf("into GPIO interrupt!\r\n");
}
任务函数:
void Task1_task(uint32_t task_init_data)
{
int counter = 0;
while(1) {
counter++;
/*Write your code here... */
printf("Task1_task is running!\r\n");
_time_delay_ticks(1);
}
}
系统运行的结果是:
Task1_task is running!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
.........
这样一直打印 into GPIO interrupt! 而未执行到任务打印 Task1_task is running!。
如果外部输入中断信号使得产生中断的频率小些,为30Hz.那么系统执行的情况是:
Task1_task is running!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
Task1_task is running!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
into GPIO interrupt!
................
这样的话,任务在一定的时间间隔后,还是可以得到执行的,不至于被中断抢占到饿死,无法执行。
那为什么在外部中断频率高了,就会出现任务被饿死呢?怎么才能解决这个问题?请各位能给予指点一下,谢谢!
|