是否可以在不激活中断的情况下模拟中断的动作。
我问的原因是因为我使用的微控制器只允许我在任何给定时间激活一个中断。当我创建一个时间触发系统时,我已经为定时器设置了一个中断。
基本上我必须创建一个 TT 系统(时间触发),以便定期部署功能。我正在创建一个数据记录系统,所以字符从 UART 进来并被存储和记录。我需要为串行端口设置一个中断,这将在用户输入字符时发生。所以我需要设计一个有两个中断的系统,一个用于定时器,一个用于串口。但是控制器不允许同时激活两个中断。
如果这令人困惑,我真的很抱歉,我已经将数据表的链接发布到控制器,这是我的接口代码
void Menu_Update(void)
{
uint8_t x=010;
char i;
i= (char)x;
// Perform an appropriate action based on the current state.
//Disable_Interrupt();
//Enable_System_Interrupt(UART1);
timer_count++;
switch (menu_state)
{
case MAIN_MENU :
// Output the initial menu choices and move to the wait state.
Serial_UART_Write_String("Waiting for character input.......\r\n");
Serial_UART_Write_String("To view data, enter 'a' \r\n");
menu_state = MENU_WAIT ;
break;
case MENU_2:
Serial_UART_Write_String("\r\nWould you also like to store this character as well?\r\n");
Serial_UART_Write_String("Yes Enter 'y' \r\n");
Serial_UART_Write_String("No Enter 'n' \r\n");
menu_state = MENU_WAIT ;
break;
case MENU_WAIT :
// Do nothing unless user input was detected.
default:
if (Serial_UART_Received_Data())
{
const char value = Serial_UART_Read();
temp = value;
Serial_UART_Write_String("\r\n***Character: ");
Serial_UART_Write_Char(value);
Serial_UART_Write_String(" has been received***\r\n");
if (value == 'a'||menu_check==1)
{
menu_check =1;
if (value == 'y')
{
menu_check =0;
menu_state = WRITE_CHAR;
}
if (value == 'n')
{
Serial_UART_Write_String("\r\nSegment format -> ");
Serial_UART_Write_String("Character count.Time\r\n");
menu_check =0;
menu_state = DISPLAY;
}
if (menu_check==1)
{
menu_state = MENU_2;
}
}
else
{
menu_state = WRITE_CHAR;
}
}
break;
case WRITE_CHAR:
character_array_storage[character_count]=temp;
charac_time = timer_count - ref_timer;
timer_interval_array[character_count]=charac_time;
character_count++;
Serial_UART_Write_String("\r\n***Character Stored***\r\n");
menu_state = MAIN_MENU;
break;
case DISPLAY:
assign_value(character_count,charac_time);
Serial_UART_Write_String("\r\n***Segments Updated***\r\n");
menu_state = MAIN_MENU;
break;
}
//Disable_Interrupt();
//Enable_System_Interrupt(TIMER0);
}
void Enable_System_Interrupt(const uint32_t int_source)
{
Status_Reg_Set((Status_Reg_Get()& 0xFFFFF8FF) | (int_source << 8));
}
void Status_Reg_Set(uint32_t value)
{
__asm volatile("mtc0 %0, $12" :: "d" ((unsigned long)(value)));
}
数据表 谢谢