Quality RTOS & Embedded Software

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


Loading

STM32F107 using eclipse

Posted by Do on May 22, 2013
Hi,
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. */
#include
#include
/* 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. */
#define TASKPRIORITY1 (tskIDLE_PRIORITY + 1)
#define TASKPRIORITY2 (tskIDLE_PRIORITY + 2)
#define TASKPRIORITY3 (tskIDLE_PRIORITY + 3)

#define mainFLASH_TASK_PRIORITY( tskIDLE_PRIORITY + 1 )

/* 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];
}LcdMsg;

/*-----------------------------------------------------------*/

/*
* 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) {

prvSetupHardware();

setbuf(stdout,NULL);
/* Start the scheduler. */
printf(\"########################## MINI PROJET CS530 ################\\n\");
vTaskStartScheduler();
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 )
{
printf(\"DEBUG : CREATION SEMAPHORE SUCCED\\n\");
}
/* TASKPRIORITY1 = (tskIDLE_PRIORITY + 1) et TASKPRIORITY1 = (tskIDLE_PRIORITY + 2) */

/* 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 */
RCC_APB2PeriphClockCmd(
RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE
| RCC_APB2Periph_AFIO, ENABLE);

/* Set the Vector Table base address at 0x08000000 */
#ifdef IAP_VECT_TAB_RELOCATE
NVIC_SetVectorTable(NVIC_VectTab_FLASH_RELOCATED, 0x0);
#else
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
#endif

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

/* Configure HCLK clock as SysTick clock source. */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

/* 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);
TIM_Cmd(TIM2, 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.
STM3210C_LCD_Init();
// Display a startup message.
LCD_Clear(White);
LCD_SetTextColor(Green);
LCD_DisplayStringLine( Line0, ( unsigned char * ) \" www.FreeRTOS.org\" );
LCD_SetTextColor(Blue);
LCD_DisplayStringLine( Line1, ( unsigned char * ) \" Project 4 example\" );
LCD_SetTextColor(Black);

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.

Regards.

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.

Regards.

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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner