全部博文(320)
分类: 项目管理
2010-08-13 00:01:46
在SDRAM上跑NIOS自带的uc/os tutorial工程模块,编译时发生以下的错误:
make -s all includes
Creating generated_app.mk...
Creating
system.h...
2008-9-23 10:32:54 - (严重) generate:
java.lang.IllegalStateException: java.lang.IllegalStateException:
java.lang.NumberFormatException: empty String
make[1]: ***
[system_description/../obj/system.h-t] Error 1
make: *** [system_project]
Error 2
Build completed in 11.922 seconds
去网上搜了一下,发现原因是没有加定时器,于是回去重新加了定时器,搞掂~
另外,NIOS IDE自带的演示程序hello_led被我更改以后变成如下的代码:
#include
#include "includes.h"
#include
"system.h"
#include "alt_types.h"
#include "altera_avalon_pio_regs.h"
#define TASK_STACKSIZE 2048
OS_STK
task1_stk[TASK_STACKSIZE];
OS_STK task2_stk[TASK_STACKSIZE];
#define TASK1_PRIORITY 1
#define TASK2_PRIORITY 2
void task1(void* pdata)
{
alt_u8 led = 0x2;
alt_u8 dir =
0;
volatile int i;
while (1)
{
if (led & 0x81)
{
dir = (dir ^ 0x1);
}
if (dir)
{
led = led >> 1;
}
else
{
led = led << 1;
}
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led);
i = 0;
while (i<200000)
i++;
OSTimeDlyHMSM(0,
0, 3, 0);
}
}
void task2(void* pdata)
{
while (1)
{
printf("Hello from
task2\n");
OSTimeDlyHMSM(0, 0, 3, 0);
}
}
int main(void)
{
OSTaskCreateExt(task1,
NULL,
(void
*)&task1_stk[TASK_STACKSIZE],
TASK1_PRIORITY,
TASK1_PRIORITY,
task1_stk,
TASK_STACKSIZE,
NULL,
0);
OSTaskCreateExt(task2,
NULL,
(void
*)&task2_stk[TASK_STACKSIZE],
TASK2_PRIORITY,
TASK2_PRIORITY,
task2_stk,
TASK_STACKSIZE,
NULL,
0);
OSStart();
return 0;
}
该程序是在控制台打印字符串的同时控制流水灯。运行之后发现流水灯移动很缓慢,于是改了OSTimeDlyHMSM(0, 0, 3, 0),把其中的参数改为0,0,0,10。这个函数的作用是按小时、分、秒、毫秒来定义时间,任务调用OSTimeDlyHMSM函数后,一旦规定的时间它马上就会处于就绪态。之所以更改之前的流水灯执行很慢,就是因为等待时间为3秒,流水灯每三秒才移动一次,更改之后变为10ms即可就绪,因此流水灯就可以顺畅的移动起来了。