如何解决Proteus 总是在特定时间出错在本例中为 1.75 秒
我最近在大学项目中使用 FreeRTOS,但不知何故我的 proteus 总是有这个致命错误(每次它的差异错误但总是致命错误,有时违反模块 DSIM.dll,有时其他 .dll(s))。起初我认为这与我的代码有关,所以我尝试使用另一个示例代码(来自互联网的简单模板,可以使 LED 闪烁,并不复杂)但它仍然在 1.75 秒时出错,即使在那个人的演示中工作出色。我认为这与 xTaskDelay 原因有关,当我评论任务的延迟线时(我认为它的单一任务是因为唯一正在运行的任务只是具有更高优先级的任务)程序工作。提前致谢
#include <Arduino_FreeRTOS.h>
void setup()
//Initialize the Serial Monitor with 9600 baud rate
{
Serial.begin(9600);
Serial.println(F("In Setup function"));
//Set the digital pins 8 to 11 as digital output pins
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
//Create three tasks with labels Task1,Task2 and Task3 and assign the priority as 1,2 and 3 respectively.
//We also create the fourth task labeled as IdelTask when there is no task in
//operation and it has the highest priority.
xTaskCreate(MyTask1,"Task1",100,NULL,1,NULL);
xTaskCreate(MyTask2,"Task2",2,NULL);
xTaskCreate(MyTask3,"Task3",3,NULL);
xTaskCreate(MyIdleTask,"IdleTask",NULL);}
//We can change the priority of task according to our desire by changing the numeric’s //between NULL texts.
void loop()
{
//There is no instruction in the loop section of the code.
// Because each task executes on interrupt after specified time
}
//The following function is Task1. We display the task label on Serial monitor.
static void MyTask1(void* pvParameters)
{
while(1)
{
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
Serial.println(F("Task1"));
vTaskDelay(100/portTICK_PERIOD_MS);
}
}
//Similarly this is task 2
static void MyTask2(void* pvParameters)
{
while(1)
{ digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
Serial.println(F("Task2"));
vTaskDelay(110/portTICK_PERIOD_MS);
}
}
//Similarly this is task 3
static void MyTask3(void* pvParameters)
{
while(1)
{
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
Serial.println(F("Task3"));
vTaskDelay(120/portTICK_PERIOD_MS);
}
}
//This is the idle task which has the lowest priority and calls when no task is running.
static void MyIdleTask(void* pvParameters)
{
while(1)
{
digitalWrite(8,LOW);
digitalWrite(10,HIGH);
Serial.println(F("Idle state"));
delay(50);
}
}
解决方法
事实证明 Proteus 应用程序有点损坏,所以我去谷歌下载那些 .dll(s) 文件
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。