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 used FlashFS example and RTX_CAN example in RL folder examples in keil uvision and combined them together.But less than one minute I face with Runtime error and in debug mode the code climb to os_error function in RTX_Conf_CM.c.
For playing .Wave file i must to modify RTX_Conf_CM.c as below:
#ifndef OS_TASKCNT #define OS_TASKCNT 26 #endif #ifndef OS_PRIVCNT #define OS_PRIVCNT 1 #endif #ifndef OS_STKSIZE #define OS_STKSIZE 75 #endif #ifndef OS_STKCHECK #define OS_STKCHECK 1 #endif #ifndef OS_RUNPRIV #define OS_RUNPRIV 1 #endif #ifndef OS_CLOCK #define OS_CLOCK 100000000 #endif #ifndef OS_TICK #define OS_TICK 15 #endif #ifndef OS_ROBIN #define OS_ROBIN 1 #endif #ifndef OS_ROBINTOUT #define OS_ROBINTOUT 10 #endif #ifndef OS_TIMERCNT #define OS_TIMERCNT 0 #endif #ifndef OS_FIFOSZ #define OS_FIFOSZ 16 #endif #ifndef OS_MUTEXCNT #define OS_MUTEXCNT 500 #endif
after for example 20s or 30s or more trying for fclose() command i face to runtime error. Maybe the processor has problem with fclose() command .
this is the code in my Receive data funcion:
__task void loop_1(void){ for(;;){ os_dly_wait(1); //os_mut_wait(&mut_IO, 0xffff); //os_mut_wait(&mut_CAN, 0xffff); /*---------------------------Music is played-----------------------------------------*/ if(/*!(Rx1_val&1<<FAST_REL)&&*/music_start==0) { initcard: tsk_lock(); if(finit () == 0) { tsk_unlock (); } else{ tsk_unlock (); os_dly_wait(50000); goto initcard; } next1="M:\\_1.wav"; // os_mut_wait(mut_IO, 0xffff); os_dly_wait(1000); tsk_lock (); fp = fopen (next1,"rb"); tsk_unlock (); if (fp == NULL) { os_dly_wait(50000); goto initcard; } music_start=1; } if(music_start==1) { file_read_bac=feof(fp); if(!file_read_bac) { tsk_lock (); ch=fgetc(fp); tsk_unlock (); LPC_DAC->DACR= (1024/255)*ch<<6|0x10000; } else { rewind(fp); closing: tsk_lock(); if (!fclose (fp)) { tsk_unlock (); } else if(fclose (fp)==EOF) { tsk_unlock (); os_dly_wait(50000); goto closing; } os_dly_wait(1000); flushing: tsk_lock(); if (fflush (fp)) { tsk_unlock (); os_dly_wait(50000); goto flushing; } else tsk_unlock (); music_start=0; } } } }
This is my CAN task:
__task void task_rece_CAN (void) { CAN_msg msg_rece; for (;;) { /* When message arrives store received value to global variable Rx_val */ os_mut_wait (&mut_CAN, 0xffff); if (CAN_receive (1, &msg_rece, 0xFFFF) == CAN_OK) { //os_evt_clr(0x0001,t_task_send_CAN); // os_mut_wait(mut_IO, 0xffff); Rx_val = msg_rece.data[0]; Rx1_val = msg_rece.data[1]; Rx2_val = msg_rece.data[2]; Ext1 = msg_rece.data[3]; Ext2 = msg_rece.data[4]; Rx3_val = msg_rece.data[5];//sensors Rx4_val = msg_rece.data[6];//init_elevator mainboard_receive_frame(); os_evt_set(0x0001,t_task_send_CAN); } os_mut_release (&mut_CAN); } }
when i disable CAN task the sd card reading is fine but when i enable both task i face with Runtime error .the problem is on fclose() or fopen() I think I have problem with SPI function.because FlashFS example is not RTX. What should i do?is it any Flash Fs example which can work with RTX?or can you help me to improve my code?