Quality RTOS & Embedded Software

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




Loading

Trace macro failing to be called (not compiled)

Posted by erupter on June 4, 2014

I have a basic project running, but tasks are not doing what I want so I would like to use the traceTASKSWITCHEDIN/OUT macros to output something to a logic analyzer.

So here is my code


void setLogOutput (unsigned long c)
{
    int a;
    if (c == 0)
        a = 0;
}

#define traceTASK_SWITCHED_IN() setLogOutput(pxCurrentTCB->uxTaskNumber)
#define traceTASK_SWITCHED_OUT() setLogOutput(0)
#include "FreeRTOS.h"

Obviously setLogOutput doesn't do anything right now, and I know it. But the point is that neighter SWITCHEDIN nor SWITCHEDOUT are ever called or compiled. Breakpoints in tasks.c are broken. I cannot understand what I am doing wrong, could anybody please help me?


Trace macro failing to be called (not compiled)

Posted by rtel on June 4, 2014

Where have you defined the macros?

The easiest place to put them, to get the correct include order, is at the bottom of FreeRTOSConfig.h.

Regards.


Trace macro failing to be called (not compiled)

Posted by heinbali01 on June 4, 2014

Hi,

You could try:

~~~~~~ volatile unsigned int dummy; void setLogOutput (unsigned long c) { dummy++; } ~~~~~~

It is possible that optimiser ignores the code, because it does nothing.

GCC is very clever with this: it sees when a variable is only used in the left-hand size of expressions, and in that case it will never be implemented. 'volatile' might help or better: print the variable somewhere.

Regards.


Trace macro failing to be called (not compiled)

Posted by jdurand on June 4, 2014

I've been seeing GCC get more and more clever about working around my ways to keep variables/code from being deleted. There was a time when global variables were safe, but not now.

I've tried debugging with no optimization, but that just blows the code up where it doesn't fit. I now run with -Og which seems to be a reasonable compromise most of the time.

On 06/04/2014 09:56 AM, Hein Tibosch wrote: > GCC is very clever with this: it sees when a variable is only used in > the left-hand size of expressions, and in that case it will never be > implemented. 'volatile' might help or better: print the variable > somewhere.

Jerry Durand, Durand Interstellar, Inc. www.interstellar.com tel: +1 408 356-3886, USA toll free: 1 866 356-3886 Skype: jerrydurand


Trace macro failing to be called (not compiled)

Posted by heinbali01 on June 4, 2014

Yes indeed, gcc also makes global variables disappear, even if they appear in several modules (as LHS only).

~~~~~~ const char ipmarker[32] = "dEfAuLtIp192.168.2.116"; void somefunction() { asm ("" : : "r" (ipmarker) : "cc"); } ~~~~~~

This trick worked to get a const string included in the code without ever actually reading it. Note that some_function() must be called


Trace macro failing to be called (not compiled)

Posted by erupter on June 10, 2014

Sorry I thought I answered this but evidently I didn't.

Putting the macro at the end of FreeRTOSConfig.h solved my problem.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists