Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Local data changes after running many hours

Posted by vicui on October 7, 2013

All:

void aaa(void) { int data[8];

bbb(data);
...

} my task call some code like above. data buffer is set in bbb function, but data[0] change afer bbb function return. the issue happens afer running many hours. I try to extend task stack size and system stack size, but still happen. at that time, no task switch but probaly interrupt coming in. CORTEX M3 save contex by HW. anyone meet the same issue ?

vincent


Local data changes after running many hours

Posted by richardbarry on October 7, 2013

Have you been through the items here: http://www.freertos.org/FAQHelp.html and as you are using a Cortex-M also here: http://www.freertos.org/RTOS-Cortex-M3-M4.html

Are you using FreeRTOS V7.5.2? If so defining configASSERT() will trap many of the common errors described on the Cortex-M specific link above.

Regards.


Local data changes after running many hours

Posted by vicui on October 9, 2013

I always use FreeRTOS v7.5.2 and enable configASSERT(), when the issue happen, there is no any ASSERT happens. the interrupt priority follows above link completely . Is there any idea ?


Local data changes after running many hours

Posted by richardbarry on October 9, 2013

Do your debug tools allow you to set watchpoints on data being written to? If so, place a break point the byte that is getting overwritten so the debugger stops when the value changes and you can see what was written to it. The problem will either be a misconfiguration (but if the recommendations on the above links are being followed that is less likely) or an simple application error.

Regards.


Local data changes after running many hours

Posted by vicui on October 9, 2013

Sorry, I need to buy the emulator!

I post my interrupt configure as following

define configKERNELINTERRUPTPRIORITY 255
define configMAXSYSCALLINTERRUPT_PRIORITY 191
define configLIBRARYKERNELINTERRUPT_PRIORITY 15

and initialize interrupt NVIC as following static void RS485NVICConfig(void) { NVICSetPriority( USART1IRQn, configLIBRARYKERNELINTERRUPTPRIORITY ); NVICEnableIRQ( USART1_IRQn ); }

containly, there are other many interrupt in system.

compared to old code, I only add a 485 receive semaphore in receiving 485 packet. rs485rxsemaphore = xSemaphoreCreateCounting(8, 0); only it receive correct packet by interrupt, it will call xSemaphoreGiveFromISR( rs485rxsemaphore, &xHigherPriorityTaskWoken );

Is it possible that the code cause the issue ?

Vincent


Local data changes after running many hours

Posted by davedoors on October 9, 2013

If the 15 is right or not depends on the chip you are using. Which is it?


Local data changes after running many hours

Posted by vicui on October 9, 2013

Cortex M3


Local data changes after running many hours

Posted by richardbarry on October 9, 2013

Yes - you mentioned that already. Dave's question is related to the fact that different Cortex-M3 implementations have a different number of priority bits, and that effects the setting of configLIBRARYKERNELINTERRUPT_PRI (I think this was explained on the web page you are already been referenced to).

So which Cortex-M3 device family are you using? For example, is it an STM32F, LPC17xx, LM3Snnn, etc.

Regards.


Local data changes after running many hours

Posted by vicui on October 9, 2013

STM32F2X7


Local data changes after running many hours

Posted by richardbarry on October 9, 2013

In which case I think the 15 is correct.

Regards.


Local data changes after running many hours

Posted by vicui on October 16, 2013

I trace the issue and find some strange case which may be related with interrupt mixxing. in my SLIP protocol, DB and DD BYTES are used to represent DB (DB data byte will appear as DBDD), but the a changeed data including DD BYTE. it seems that SLIP response data is not synchronize with current SLIP commands. static uint8t rs485rxroutine(void) { uint8t ret = SLIP_OK;

if (xSemaphoreTake( rs485_rx_semaphore, 50) != pdTRUE)
{
    ret = SLIP_TIMEOUT;
}
rs485_rx_count = 0;

return ret;

} my 485 rx handle wait 50ms to take the samephore . and the samephore is counting and initialized as rs485rxsemaphore = xSemaphoreCreateCounting(8, 0); which release in 485 interrupt handle

void USART1IRQHandler(void) { portBASETYPE xHigherPriorityTaskWoken = pdFALSE;

if (USART_GetFlagStatus(USART1, USART_FLAG_ORE) == SET)
{
    USART_ClearFlag(USART1,USART_FLAG_ORE);	
	USART_ReceiveData(USART1);
}

if(USART_GetITStatus(USART1, USART_IT_RXNE) == SET)

{ uint8_t tmp = 0;

    USART_ClearITPendingBit(USART1, USART_IT_RXNE);
	tmp = (USART_ReceiveData(USART1) & 0xFF);
	slipcmdrspbuffer[rs485_rx_count++] = tmp;
    if (rs485_rx_count >= SLIP_CMDRSP_BUF_SIZE)
    {
        slipcmdrspbuffer[2] = SLIP_NACK;
        cmdrsppacketsize = 5;
        xSemaphoreGiveFromISR( rs485_rx_semaphore, &xHigherPriorityTaskWoken );
    }
    else if (rs485_rx_count == 1)
    {
        if (tmp != SLIP_START)
        {
            rs485_rx_count = 0;
        }
    }
    else if((rs485_rx_count < SLIP_ACKNACK_PACKET_SIZE) && (rs485_rx_count > 1))
	{
		if (tmp == SLIP_START)
		{
			rs485_rx_count = 0;
            slipcmdrspbuffer[rs485_rx_count++] = tmp;
		}
	}
	else if(rs485_rx_count == SLIP_ACKNACK_PACKET_SIZE)
	{
		if (slipcmdrspbuffer[2] == SLIP_NACK)
		{
			cmdrsppacketsize = rs485_rx_count;
            xSemaphoreGiveFromISR( rs485_rx_semaphore, &xHigherPriorityTaskWoken );
		}
	}
	else if (rs485_rx_count > (SLIP_ACKNACK_PACKET_SIZE + 1))
	{
	 	if (slipcmdrspbuffer[rs485_rx_count - 1] == SLIP_END)
		{
			cmdrsppacketsize = rs485_rx_count;
            xSemaphoreGiveFromISR( rs485_rx_semaphore, &xHigherPriorityTaskWoken );
		}		
	}

}

portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

}

meanwhile, I also use the 485 channel to get other sensor's data. and I use rs485semwait(); and rs485semsignal(); to protect the 485 channle in used. Is there a possible that system get the last SLIP command response data after issue new SLIP command?


Local data changes after running many hours

Posted by vicui on October 23, 2013

Rechard: I find the root cause now , once the issue happen, device accept 2 ACK data in slip reponse data, this also meet SLIP protocol in format. I don't verify the second ACK. now, only check the data integerity and filter this time. the issue disappear !

thank you for your help

vincent


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS