vTaskDelay cause system halt

vicui wrote on Tuesday, August 20, 2013:

I use the portable files under \FreeRTOSV7.5.2\FreeRTOS\Source\portable\RVDS\ARM_CM3 and configure NVIC for each IRQ by refer to FreeRTOS\Demo\CORTEX_A2F200_IAR_and_Keil… system can’t run .
I also find that the demo don’t use the NVIC_SETGROUP, only call NVIC_setPrioirty and  NVIC_enableIRQ function to configure, does it work?

rtel wrote on Tuesday, August 20, 2013:

I use the FreeRTOSV7.5.2\FreeRTOS\Source\portable\GCC\ARM_CM3 port.c and portmirco.h to compile , and compile fail. more error and worning happen.

do need update it MDKv4.72a ?

You can’t build GCC files with the Keil compiler.  That is why there is a separate port for Keil (and IAR, and Tasking…)

I also find that the demo don’t use the NVIC_SETGROUP

The only time you should need to set the priority group is if you are using the STM32 peripheral driver libraries.  In all other cases you can leave it at its default value, so the port layer code does not set it.  As you are using the libraries you must set it, as we have already discussed.

Regards.

vicui wrote on Tuesday, August 20, 2013:

I get it done . rechards is right , the validate interrupt prioirty trap is catched. it happen in…\USER\FreeRTOS_v7.5.2\portable\MDK-ARM\ARM_CM3\port.c 650
any ISR calling FREERTOS API 's prioity must set to lowest priolirty, i set it to configKERNEL_INTERRUPT_PRIORITY which define in freertosconf.h
/* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY         255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */

/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15.  This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15

i have eeprom, serial, rs485, rs485plus, ethernet interrupt, only ethenet use freertos api .
so, i set other interrupt prioity to 0, and set ethernet interrtup to configKERNEL_INTERRUPT_PRIORITY.
and before task schedule, i set NVIC GROUP TO 4.
all things seems work now , I also enable ASSERT to catch other trap if it exist.

rtel wrote on Tuesday, August 20, 2013:

I change my NVIC code as following

… but that is still calling NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); instead of NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

Regards.

vicui wrote on Tuesday, August 20, 2013:

I changeed it to NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
it works well

vicui wrote on Tuesday, August 20, 2013:

HI rechard:

I post all interrrupt configuration as following:
NVIC_SetPriority( SERIAL_PORT_IRQn, 0 );
    NVIC_EnableIRQ( SERIAL_PORT_IRQn );
NVIC_SetPriority( USART1_IRQn, 0 );
    NVIC_EnableIRQ( USART1_IRQn );
NVIC_SetPriority( USART3_IRQn, 0 );
    NVIC_EnableIRQ( USART3_IRQn );

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_SetPriority( ETH_IRQn, configKERNEL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( ETH_IRQn );

/* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY         255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */

/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15.  This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15

only ethernet ISR use FreeRTOS api, so above interrupt configruation is okay ?

vincent

vicui wrote on Tuesday, August 20, 2013:

before RTOS runing, I set EEPROM RX and TX interrupt as followed
void eeprom_nvic_update(void)
{
   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_SetPriority( I2C_EE_DMA_TX_IRQn, configKERNEL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( I2C_EE_DMA_TX_IRQn );
    NVIC_SetPriority( I2C_EE_DMA_RX_IRQn, configKERNEL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( I2C_EE_DMA_RX_IRQn );
}
,then, I use it to read data from EEPROM, system halt in read eeprom API.
I change configKERNEL_INTERRUP_PRIOIRTY to 0, it works… why ?

vicui wrote on Tuesday, August 20, 2013:

wooo, system halt again . configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ) is catched !!! what does it mean ?

davedoors wrote on Tuesday, August 20, 2013:

It means you are passing a null pointer into the function. That would probably explain why you are having so many problems.

Plus the interrupt priority should probably be set to configLIBRARY_KERNEL_INTERRUPT_PRIORITY as you are passing it into a library function. Check how the function you are calling expects the priority to be passed in, and reread the page about setting Cortex interrupt priorities on the FreeRTOS.org site.

vicui wrote on Tuesday, August 20, 2013:

I2C’s RX and TX interrupt 's prority define to configLIBRARY_KERNAL_INTERRUPT_PRIORITY , RX and TX api can’t work before freertos running.
   /* Configure and enable I2C DMA TX Channel interrupt */
    NVIC_SetPriority( I2C_EE_DMA_TX_IRQn, configLIBRARY_KERNEL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( I2C_EE_DMA_TX_IRQn );
    NVIC_SetPriority( I2C_EE_DMA_RX_IRQn, configLIBRARY_KERNEL_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( I2C_EE_DMA_RX_IRQn );

but I set the priority to 0, it works.

   /* Configure and enable I2C DMA TX Channel interrupt */
    NVIC_SetPriority( I2C_EE_DMA_TX_IRQn, 0 );
    NVIC_EnableIRQ( I2C_EE_DMA_TX_IRQn );
    NVIC_SetPriority( I2C_EE_DMA_RX_IRQn, 0 );
    NVIC_EnableIRQ( I2C_EE_DMA_RX_IRQn );

other interrrupt works with configLIBRARY_KERNEL_INTERRUPT_PRIORITY priority. 
anyone tell me why ? it is strange

davedoors wrote on Tuesday, August 20, 2013:

Interrupts up to the syscall priority level are masked until the scheduler is started. It should work when the scheduler is running, just ensure to set the priority down before you call vTaskStartScheduler().

vicui wrote on Tuesday, August 20, 2013:

for the trap assert happen in configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); in xQueueGenericSend function , but xQueueGenericSend is called in xQueueCreateMutex, I don’t enable configUSE_MUTEXES in freertosconfig.h

I am confusing about this

vicui wrote on Wednesday, August 21, 2013:

Hi:

system halt again, confASSERT still trap in …\USER\FreeRTOS_v7.5.2\queue.c 560
I define following in freertosconf.h
#define configUSE_MUTEXES               0
#define configUSE_COUNTING_SEMAPHORES   1

i really don’t know when call the xQueueGenericSend function in runnig time. any suggestion ?

vicui wrote on Wednesday, August 21, 2013:

Trace code and find that xSemaphoreGive call the function . but don’t find where take this

vicui wrote on Wednesday, August 21, 2013:

I found that Fatfs crashed once the trap happen, so I trace the code and find that I enable _FS_REENTRANT in ffconf.h and set
#define _FS_TIMEOUT 100 /* Timeout period in unit of time ticks */
#define _SYNC_t xQueueHandle /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc… */
in syscall.c there are api call   xSemaphoreCreateMutex , xSemaphoreTake , xSemaphoreGive, i think the trap happen in here. but I don’t know why it happen, the TIMEOUT value is small ?

vincent

rtel wrote on Wednesday, August 21, 2013:

Unfortunately we cannot support third party code - but from experience of past support requests I would guess your problems come from the implementation of your FATfs driver.

Regards.

vicui wrote on Thursday, August 22, 2013:

Hi, I print the xQueue value when the ASSERT happen (queue.c 560), the value is not of those semaphore I create. it is related with ethernet, because the ASSERT never happen once I plug out cable. Does it mean that my LWIP porting has problem ?

vicui wrote on Thursday, August 22, 2013:

Sorry, the ASSERT stil happen when plug out cable …

rtel wrote on Thursday, August 22, 2013:

I print the xQueue value when the ASSERT happen

Do you mean print it to a console?  Are you trying to do this without a debugger?  If you have file system and Ethernet code you have a large code base and working without a debugger will be very inefficient.

Regards.

vicui wrote on Thursday, August 22, 2013:

I reduce my application in my system, it only has 2 function, one is write a data log by interval 0.5s and another task is polling data via 485. even this, the ASSERT still happen . I want to know if FreeRTOS has Own semaphore or mutex ?
other, so write file frequency will cause the ASSERT ?