Forum Discussion
Altera_Forum
Honored Contributor
13 years agoIt seems like this problem is related to the FreeRTOS operating system I am using.
This is my code:/* Standard includes. */
# include <stddef.h>
# include <stdio.h>
# include <string.h>
/* Scheduler includes. */
# include "FreeRTOS.h"
# include "task.h"
# include "queue.h"
/* NiosII includes. */
# include "system.h"
# include "altera_avalon_pio_regs.h"
int main()
{
unsigned int i = 200;
unsigned int j = 0;
unsigned char led=0x01;
portBASE_TYPE res;
printf("hello world!\n");
led =0xff;
IOWR(LED_PIO_BASE,0,led);
i=50000; while(i--);
res = xTaskCreate(
call_back1,
( signed char * ) "Task1",
configMINIMAL_STACK_SIZE,
NULL,
1,
NULL
);
if ( res != pdPASS )
printf("erro,fail to create task:%d\n", res);
else
printf("success to create task\n");
xTaskCreate(
call_back2,
( signed char * ) "Task2",
configMINIMAL_STACK_SIZE,
NULL,
2,
NULL
);
led =0xaa;
IOWR(LED_PIO_BASE,0,led);
printf("start schedule\n");
vTaskStartScheduler();
while(1);
}
void call_back1(void* param)
{
for(;;)
{
IOWR(LED_PIO_BASE,0,0x0f);
printf("run task1\n");
vTaskDelay(2000);
}
}
void call_back2(void* param)
{
for(;;)
{
IOWR(LED_PIO_BASE,0,0xf0);
printf("run task2\n");
vTaskDelay(1000);
}
}