Hi all,
I’m new to FreeRTOS.
Try to use version 7.6.0 ported to atmega128
atxmega128A1 and CodevisionAVR.
The demo does not work. I managed to reduce the problem to a simple program:
When creating a reading queue task, the program fails, the LEDs stop flashing. Without reading queue task, the led4 flashes 5 times and then stops because the queue is full and led0 toggle every 1 sec.
If I set priority 0 for the task vReadQueue, led4 and led5 light up and stay lit and led0 not flashes. Timer intrerrupt is triggering, and program is stuck in file list.c, function: void vListInsert( xList * const pxList, xListItem * const pxNewListItem ) in the for loop.
~~~~~~
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
{
/* There is nothing to do here, we are just iterating to the
wanted insertion position. */
// here it loops forever
}
~~~~~~~
I tried demo port AVR
ATMega323WinAVR modified for ATmega128 and WinAVR and it does not work to.
~~~~~~
define mainLEDTASKPRIORITY 1
define mainTESTQUEUEPRIORITY 2
define mainTIMP0 ( portTickType ) 1000 / portTICKRATEMS
define mainTIMPQWRITE ( portTickType ) 500 / portTICKRATEMS
define mainTIMPQREAD ( portTickType ) 0xffff
define mainNO_DELAY ( portTickType ) 0
//definitii prototipuri
static void vLed0( void *pvParameters );
void vWriteQueue( void *pvParameters );
void vReadQueue( void *pvParameters );
void setTestQueue(char prioritate);
static xQueueHandle xCoada;
//xSemaphoreHandle xSemaphore;
void main(void)
{
vParTestInitialise();
/* Create the tasks defined within this file. */
xTaskCreate( vLed0, ( signed char * )”led0″, configMINIMAL
STACKSIZE, NULL, mainLED
TASKPRIORITY, NULL );
//vStartPolledQueueTasks( mainQUEUE
POLLPRIORITY );
//vAltStartComTestTasks( mainCOM
TESTPRIORITY, 38400, led6 );
setTestQueue(mainTEST
QUEUEPRIORITY);
vTaskStartScheduler();
while (1)
{
; //nu trebuie sa ajunga aici;
}
}
void setTestQueue(char prioritate)
{
xCoada=xQueueCreate(5, sizeof(char));
//xSemaphore=xSemaphoreCreateBinary();
xTaskCreate( vWriteQueue, ( signed char * ) “QProdNB”, configMINIMAL
STACKSIZE, NULL, prioritate – 1, ( xTaskHandle * ) NULL );
/* — next task, if it is created, block all program —
/
xTaskCreate( vReadQueue, ( signed char * ) “QConsNB”, configMINIMAL_STACK_SIZE, NULL, prioritate, ( xTaskHandle * ) NULL );
/ ————————— */
}
void vWriteQueue( void *pvParameters )
{
portTickType xLastWakeTime;
char c=0;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount();
for( ;; )
{
c++;
//if( xSemaphoreGive( xSemaphore ) == pdPASS )
if( xQueueSend(xCoada, &c, mainNO
DELAY ) == pdPASS )
{
vParTestToggleLED(led4);
}
vTaskDelayUntil( &xLastWakeTime, ( portTickType ) 333 / portTICKRATE_MS );
}
}
void vReadQueue( void *pvParameters )
{
char c=0;
for( ;; )
{
//if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 / portTICK_RATE_MS ) == pdPASS )
if( xQueueReceive(xCoada, &c, portMAX_DELAY ) == pdPASS ) // <– Here get stuck
{
vParTestToggleLED(led5);
}
}
}
static void vLed0( void *pvParameters )
{
portTickType xLastWakeTime;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount();
for( ;; )
{
vTaskDelayUntil( &xLastWakeTime, mainTIMP0 );
vParTestToggleLED(led0);
}
}
~~~~~~~
my FreeRTOSconfig.h file:
~~~~~~~~
/* Call stack size for 1 task */
define configCALLSTACKSIZE 32
define configUSE_PREEMPTION 1
define configUSEPORTOPTIMISEDTASKSELECTION 0
define configUSETICKLESSIDLE 0
define configCPUCLOCKHZ ( ( unsigned portLONG ) 14745600 )
define configTICKRATEHZ ( ( portTickType ) 250 )
define configMAXPRIORITIES ( ( unsigned portBASETYPE ) 4 )
define configMINIMALSTACKSIZE ( ( unsigned portSHORT ) 65 + configCALLSTACKSIZE )
define configTOTALHEAPSIZE ( (size_t ) ( 1500 ) )
define configMAXTASKNAME_LEN ( 8 )
define configUSE16BIT_TICKS 1
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 0
define configUSERECURSIVEMUTEXES 0
define configUSECOUNTINGSEMAPHORES 0
define configQUEUEREGISTRYSIZE 10
define configUSEQUEUESETS 0
define configUSETIMESLICING 1
define configUSENEWLIBREENTRANT 0
/* Co-routine definitions. */
define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES ( 2 )
/* Hook function related definitions. */
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCHECKFORSTACK_OVERFLOW 0
define configUSEMALLOCFAILED_HOOK 0
/* Run time and task stats gathering related definitions. */
define configGENERATERUNTIME_STATS 0
define configUSETRACEFACILITY 0
define configUSESTATSFORMATTING_FUNCTIONS 0
/* Software timer related definitions. */
define configUSE_TIMERS 0
define configTIMERTASKPRIORITY 3
define configTIMERQUEUELENGTH 10
define configTIMERTASKSTACKDEPTH configMINIMALSTACK_SIZE
/* Interrupt nesting behaviour configuration. */
define configKERNELINTERRUPTPRIORITY 3
define configMAXSYSCALLINTERRUPT_PRIORITY 3
define configMAXAPICALLINTERRUPTPRIORITY 3
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
/* Optional functions – most linkers will remove unused functions anyway. */
define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskSuspend 0
define INCLUDE_xResumeFromISR 0
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
define INCLUDE_xTaskGetSchedulerState 0
define INCLUDE_xTaskGetCurrentTaskHandle 0
define INCLUDE_uxTaskGetStackHighWaterMark 0
define INCLUDE_xTaskGetIdleTaskHandle 0
define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
define INCLUDE_pcTaskGetTaskName 0
define INCLUDE_eTaskGetState 0
~~~~~~~~
Any help is appreciated.
Thanks in advance,
Adrian