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


STM32F107 using eclipse

Posted by Do on May 22, 2013
I wrote this program but when i compile i get this error:
\'TIM2_IRQn\' could not be resolved
What am i missing please?

/* Standard includes. */
/* Scheduler includes. */
#include \"FreeRTOS.h\"
#include \"task.h\"
#include \"queue.h\"
#include \"semphr.h\"
#include \"stm32f10x.h\"

#include \"stm32f10x_conf.h\"
#include \"stm32_eval.h\"
#include \"partest.h\"
#include \"STM3210C_EVAL/stm3210c_eval_lcd.h\"

/* Task priorities. */
/* Task priorities. */


/* The rate at which the flash task toggles the LED. */
#define mainFLASH_DELAY( ( portTickType ) 25 / portTICK_RATE_MS )

/* The number of nano seconds between each processor clock. */
#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )
/* The length of the queue used to send messages to the LCD task. */
#define LCD_QUEUE_SIZE( 3 )

int ledInitTask(void *pParams);
void ledTaskFunc(void *pParams);
void lcdTaskFunc(void *pParams);

typedef struct {
unsigned short toggleFrequency;
} LedInitParams;
typedef struct {
char msg[21];


* Configure the clocks, GPIO and other peripherals as required by the demo.
static void prvSetupHardware(void);

* The LCD is written two by more than one task so is controlled by a
* \'gatekeeper\' task. This is the only task that is actually permitted to
* access the LCD directly. Other tasks wanting to display a message send
* the message to the gatekeeper.
extern int sprintf(char *out, const char *format, ...);
/* Semaphore utilise pour le cas 0*/
xSemaphoreHandle xSemaphore0;
/* The queue used to send messages to the LCD task*/
xQueueHandle g_lcdQueue;


int main(void) {


/* Start the scheduler. */
printf(\"########################## MINI PROJET CS530 ################\\n\");
xTaskHandle xLed,xbutton,xledInitTask,xledTaskFunc;

/* Will only get here if there was not enough heap space to create the
idle task. */
return 0;
/* creation semaphore et taches , */
xSemaphore0 = xSemaphoreCreateCounting( 1,0);
if( xSemaphore0 != NULL )

/* tache de haute priorite */
xTaskCreate(ledTaskFunc,\"TASK1\", configMINIMAL_STACK_SIZE+1000 , NULL, TASKPRIORITY1,&xledTaskFunc);

/* Create the queue used by the LCD task. Messages for display on the LCD
are received via this queue. */
g_lcdQueue = xQueueCreate( LCD_QUEUE_SIZE, sizeof( LcdMsg ) );

xTaskCreate(lcdTaskFunc, \"Task2\", configMINIMAL_STACK_SIZE * 2, NULL, 2, NULL);


static void prvSetupHardware(void) {

USART_InitTypeDef USART_InitStructure;

/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */

/* Set the Vector Table base address at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH_RELOCATED, 0x0);
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );


/* Configure HCLK clock as SysTick clock source. */

/* Configure UART */
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl= USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

STM_EVAL_COMInit(COM2, &USART_InitStructure);



int ledInitTask(void *pParams)

unsigned long n;
LedInitParams *params;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;

params = (LedInitParams*)pParams;

/* Enable GPIOD, GPIOE clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE );

/* Configure PD13 output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOD, &GPIO_InitStructure );

// Enable timer clocks
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM2, ENABLE );

TIM_TimeBaseStructInit( &TIM_TimeBaseStructure );

// Time base configuration for timer 2 - which generates the interrupts.
n = (configCPU_CLOCK_HZ / params->toggleFrequency);

TIM_TimeBaseStructure.TIM_Period = 65535;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit( TIM2, &TIM_TimeBaseStructure );
TIM_ARRPreloadConfig( TIM2, ENABLE );

NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 13;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init( &NVIC_InitStructure );

return 0;

void ledTaskFunc(void *pParams)
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);

for (;;) {
if ( xSemaphoreTake(xSemaphore0, portMAX_DELAY) == pdTRUE ) {

GPIO_WriteBit( GPIOD, GPIO_Pin_13, Bit_SET);


void lcdTaskFunc(void *pParams)
unsigned long ulLine = Line3;
const unsigned long ulLineHeight = 24;
static char cMsgBuf[ 30 ];
LcdMsg msg;

/* The LCD gatekeeper task as described in the comments at the top of this
file. */
//Initialize the LCD.
// Display a startup message.
LCD_DisplayStringLine( Line0, ( unsigned char * ) \" www.FreeRTOS.org\" );
LCD_DisplayStringLine( Line1, ( unsigned char * ) \" Project 4 example\" );

for( ;; )
/* Wait for a message to arrive to be displayed. */
xQueueReceive( g_lcdQueue, &msg, portMAX_DELAY );

/* Clear the current line of text. */
LCD_ClearLine( ulLine );

/* Move on to the next line. */
ulLine += ulLineHeight;
if( ulLine > Line9 )
ulLine = Line3;

//Display the received text
LCD_DisplayStringLine( ulLine, ( unsigned char * )msg.msg );

RE: STM32F107 using eclipse

Posted by Richard on May 22, 2013
“What am i missing please?”

The header file that defines TIM2_IRQn. TIM2_IRQn looks like a CMSIS style definition, so you either need to include the (architecture specific) CMSIS file that defined TIM2_IRQn, or just define it yourself. The value TIM2_IRQn needs to take is completely dependent on the chip you are using, so I can't suggest a generic definition.


RE: STM32F107 using eclipse

Posted by Do on May 22, 2013
The header file that defines the TIM2_IRQn is #include \"stm32f10x.h\" and it is already included.
Is'nt what you are meaning?

RE: STM32F107 using eclipse

Posted by Richard on May 22, 2013
In which case double check the file is actually being included as you expect (write some junk into the file and see if the compiler complains), and if it is, that there are no preprocessor guards around the definition of TIM2_IRQn in the file.

This seems like a simple build problem, not related to FreeRTOS.


RE: STM32F107 using eclipse

Posted by Do on May 22, 2013
I fixed the problem.
In fact the header file was a read only file so i modified it to writable. And now it works.

[ 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