Error while activate timers functionality in project

I am using AMR CORTEX M3 LPC1833 processor in my project and develop my project in LPCXPRESSO IDE. I am using FreeRTOS OS. while adding timer functionality, I stuck in following Compile error.

ERROR: Description	Resource	Path	Location	Type
first defined here	LPC1833_lcd4bit.C	/PLC/inc	line 37	C/C++ Problem
first defined here	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
make: *** [PLC.axf] Error 1	PLC		 	C/C++ Problem
multiple definition of `adc_count'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcd_data_update'	LPC1833_lcd4bit.C	/PLC/inc	line 37	C/C++ Problem
multiple definition of `lcd_delay'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdCommand'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdConfig'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdCursor'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdData'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdDisp'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdNum'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdSend'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `lcdString'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `main'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `modbus_connected'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `modbus_init'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `modbus_rtu_addr'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `msDelay'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `read_modbusrtu_addr'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `Rx_RS485_EN'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `test_do_toggel'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `toggele_led'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `Tx_RS485_EN'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `uart_counter'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
multiple definition of `usDelay'	core_cm3.h	/lpc_chip_18xx/inc	line 1324	C/C++ Problem
undefined reference to `keyNo'	main.c	/PLC/src	line 514	C/C++ Problem
undefined reference to `keyPressed'	main.c	/PLC/src	line 514	C/C++ Problem
undefined reference to `scroll_count'	main.c	/PLC/src	line 486	C/C++ Problem
undefined reference to `scroll_count'	main.c	/PLC/src	line 514	C/C++ Problem

all above variables are defined and well compile before adding FreeRTOS timers functionality in the project. can anybody guide me how can I solve above error.?

What did you change to add timers functionality? Add the timers.c source file, set configUSE_TIMERS to 1 in FreeRTOSConfig.h, or both? What else did you change?

None of the errors above are in FreeRTOS code so my guess is there is a namespace clash with the timers.h header file - there may be two in your include directory.

I define following while adding timers,

#if configUSE_TIMERS == 1

#define configTIMER_TASK_PRIORITY 3          <-------this line I added

#ifndef configTIMER_TASK_PRIORITY
	#error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
#endif /* configTIMER_TASK_PRIORITY */

#define configTIMER_QUEUE_LENGTH 	10         <-------this line I added

#ifndef configTIMER_QUEUE_LENGTH
	#error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
#endif /* configTIMER_QUEUE_LENGTH */

#define configTIMER_TASK_STACK_DEPTH	configMINIMAL_STACK_SIZE       <-------this line I added

#ifndef configTIMER_TASK_STACK_DEPTH
	#error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
#endif /* configTIMER_TASK_STACK_DEPTH */

#endif /* configUSE_TIMERS */

Does your project compile correctly when configUSER_TIMERS is set to 0?

Your issue seems to be more a compiler thing, Are you using include guards in your own files? Multiple definition of is a consecuence of defining your symbols twice or more.

For example, in the file my_module.h:

// file: my_module.h
#ifndef _MY_MODULE_H_
#define_MY_MODULE_H_

// your declarations here...

#endif /* _MY_MODULE_H_ */

undefined reference means the compiler doesn’t find the source code of the pointed out function.

You can find more details in this NXP MCUXpresso tutorial. (Including FreeRTOS into the MCUXpress platform can be a pain in the back, I’ve been there.) You can also look for working FreeRTOS examples.

core_cm3.h is a provided CMSIS header which shouldn’t include any application code.
Is it possible that you accidentally created an application code header file with the same name as one of the CMSIS header files included by core_cm3.h ?

Thanks to all of you.

I start re-coding again from the back up code. As you mentioned there is some issue in source code, I include step by step code and compile it. The above issue solved and now I can use timers of FreeRTOS library well. Thanks again to guide me.

1 Like