We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have a bunch of tasks running in Round robin fashion. They perform the task of reading from four serial ports and polling a push button state plus one more task to print data on serial port. The problem I am facing is that if I try to initialize peripheral modules using "C1_init()" in the "task_init" task, the scheduler does not pass to the main task. But if I remove those functions the scheduler then cycles through all the tasks perfectly. I wonder if anyone can help me out here.
__task void task_uart0(void) { for(;;) { read_uart0(); os_evt_set(0x0004,id0); } } __task void task_uart1(void) { for(;;) { //read_uart1(); os_evt_set(0x0004,id0); } } __task void task_usart0(void) { for(;;) { read_usart0(); os_evt_set(0x0004,id0); } } __task void task_usart1(void) { for(;;) { read_usart1(); os_evt_set(0x0004,id0); } } __task void task_swdbutton(void) { for(;;) { if ((button_get() != 0) && (buttonState !=1)) { buttonState = 1; LED_on(0); } else if ((button_get() == 0) && (buttonState ==1)){ printf("Button press and release\n\r"); LED_blink(3); //LED_off(0); ser_print(C1,"stop\r\n"); ser_print(C2,"stop\r\n"); ser_print(C3,"stop\r\n"); buttonState = 0; } os_evt_set(0x0004,id0); } } __task void task_other(void) { for(;;){ printf("RA0: %d",REG_TC0_RA0); printf("RB0: %d",REG_TC0_RB0); printf("RC0: %d",REG_TC0_RC0); printf("CV0: %d",REG_TC0_CV0); os_evt_set(0x0004,id0); } } __task void task_main(void) { id2 = os_tsk_create(task_usart1,0); id3 = os_tsk_create(task_uart0,0); id4 = os_tsk_create(task_usart0,0); id5 = os_tsk_create(task_uart1,0); id6 = os_tsk_create(task_swdbutton,0); id7 = os_tsk_create(task_other,0); printf("Initialized\r\n"); for(;;) { // UARTS & USARTS os_evt_set(0x0004,id2); os_evt_wait_or(0x0004,0xFFFF); os_evt_set(0x0004,id3); os_evt_wait_or(0x0004,0xFFFF); os_evt_set(0x0004,id4); os_evt_wait_or(0x0004,0xFFFF); os_evt_set(0x0004,id5); os_evt_wait_or(0x0004,0xFFFF); os_evt_set(0x0004,id6); os_evt_wait_or(0x0004,0xFFFF); os_evt_set(0x0004,id7); os_evt_wait_or(0x0004,0xFFFF); } } __task void task_init(void) { for(;;){ id1 = os_tsk_self(); if(init_flg==0){ C1_init(); // functions to initialize peripheral modules C2_init(); C3_init(); Cn_start(); init_flg=1; } id0 = os_tsk_create(task_main,0); os_dly_wait(5); os_tsk_delete_self(); } }
Yes the functions do return and that is what is making me wonder.