Quality RTOS & Embedded Software

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




Loading

FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 20, 2011
Hello. Please help me with FreeRTOS 7.0.1. At this time then I start Debug Mode in the Debug Log I see only this:
Mon Jun 20 12:45:17 2011: Interface dll version 2.3.5.0
Mon Jun 20 12:45:18 2011: Device : MSP430F5438
Mon Jun 20 12:45:18 2011: External voltage : 0.0 V
Mon Jun 20 12:45:18 2011: VCC voltage : 3.0 V
Mon Jun 20 12:45:21 2011: Download complete.
Mon Jun 20 12:45:21 2011: Loaded debugee: U:\IAR Projects\FreeRTOS_7.0.1\Debug\Exe\freertos7.d43
Mon Jun 20 12:45:21 2011: Target reset


Working order:
1. Download FreeRTOS 7.0.1 c www.freertos.org.
2. Create in IAR Embedded Workbench for MSP430 4.20 empty project.
3. Add to project files from Source(tasks.c, list.c, queu.c) directory, directory Include, and all content of FreeRTOS\Source\portable\IAR\MSP430X.
4. Next I add FreeRTOSConfig.h from the folder FreeRTOS\Demo\MSP430X_MSP430F5438_IAR and create minor changes:
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/

#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( 18000000UL )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 15 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 5
#define configGENERATE_RUN_TIME_STATS 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_APPLICATION_TASK_TAG 0

#if __DATA_MODEL__ == __DATA_MODEL_SMALL__
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 110 )
#else
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 )
#endif

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1

/* The MSP430X port uses a callback function to configure its tick interrupt.
This allows the application to choose the tick interrupt source.
configTICK_VECTOR must also be set in FreeRTOSConfig.h to the correct
interrupt vector for the chosen tick interrupt source. This implementation of
vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
case configTICK__VECTOR is set to TIMER0_A0_VECTOR. */
#define configTICK_VECTOR TIMER0_A0_VECTOR

/* Prevent the following definitions being included when FreeRTOSConfig.h
is included from an asm file. */
#ifdef __ICC430__
extern void vConfigureTimerForRunTimeStats( void );
extern volatile unsigned long ulStatsOverflowCount;
#endif /* __ICCARM__ */

/* Configure a 16 bit timer to generate the time base for the run time stats.
The timer is configured to interrupt each time it overflows so a count of
overflows can be kept - that way a 32 bit time value can be constructed from
the timers current count value and the number of overflows. */
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()

/* Construct a 32 bit time value for use as the run time stats time base. This
comes from the current value of a 16 bit timer combined with the number of times
the timer has overflowed. */
#define portALT_GET_RUN_TIME_COUNTER_VALUE( ulCountValue ) \
{ \
/* Stop the counter counting temporarily. */ \
TA1CTL &= ~MC__CONTINOUS; \
\
/* Check to see if any counter overflow interrupts are pending. */ \
if( ( TA1CTL & TAIFG ) != 0 ) \
{ \
/* An overflow has occurred but not yet been processed. */ \
ulStatsOverflowCount++; \
\
/* Clear the interrupt. */ \
TA1CTL &= ~TAIFG; \
} \
\
/* Generate a 32 bit counter value by combinging the current peripheral \
counter value with the number of overflows. */ \
ulCountValue = ( ulStatsOverflowCount << 16UL ); \
ulCountValue |= ( unsigned long ) TA1R; \
TA1CTL |= MC__CONTINOUS; \
}
#endif /* FREERTOS_CONFIG_H */


5. Trying to build and got this errors:
“Error[e46]: Undefined external "vApplicationSetupTimerInterrupt" referred in port ( U:\IAR Projects\FreeRTOS_7.0.1\Debug\Obj\port.r43 )
Error[e46]: Undefined external "vConfigureTimerForRunTimeStats" referred in tasks ( U:\IAR Projects\FreeRTOS_7.0.1\Debug\Obj\tasks.r43 )”


6. Next, I add realisation of this functions in port.c:
/* The MSP430X port uses this callback function to configure its tick interrupt.
This allows the application to choose the tick interrupt source.
configTICK_VECTOR must also be set in FreeRTOSConfig.h to the correct
interrupt vector for the chosen tick interrupt source. This implementation of
vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */
void vApplicationSetupTimerInterrupt( void )
{
const unsigned short usACLK_Frequency_Hz = 32768;

/* Ensure the timer is stopped. */
TA0CTL = 0;

/* Run the timer from the ACLK. */
TA0CTL = TASSEL_1;

/* Clear everything to start with. */
TA0CTL |= TACLR;

/* Set the compare match value according to the tick rate we want. */
TA0CCR0 = usACLK_Frequency_Hz / configTICK_RATE_HZ;

/* Enable the interrupts. */
TA0CCTL0 = CCIE;

/* Start up clean. */
TA0CTL |= TACLR;

/* Up mode. */
TA0CTL |= MC_1;
}
/*-----------------------------------------------------------*/

void vConfigureTimerForRunTimeStats( void )
{
/* Ensure the timer is stopped. */
TA1CTL = 0;

/* Run the timer from the ACLK/2. */
TA1CTL = TASSEL_1 | ID__2;

/* Clear everything to start with. */
TA1CTL |= TACLR;

/* Enable the interrupts. */
TA1CCTL0 = CCIE;

/* Start up clean. */
TA1CTL |= TACLR;

/* Continuous mode. */
TA1CTL |= MC__CONTINOUS;
}
/*-----------------------------------------------------------*/


7. The bulding process has finished successfully, and next I write demo:
#include 
#include

#include "../include/FreeRTOS.h"
#include "../include/task.h"
#include "../include/queue.h"

void vHelloWorldTask( void *pvParameters ) {
for(;; ) {
printf( "Hello, world\n" );
vTaskDelay( 100 );
}
vTaskDelete( NULL );
}

void main( void )
{
//Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

if( xTaskCreate( vHelloWorldTask, "HelloWorld", 100, NULL, 1, NULL) != pdTRUE ) {
printf( "Can't create task.");
}

vTaskStartScheduler();
for(;; ) {}
}


8. And I get "Target Reset".

8*. The project structure:
“U:\IAR Projects\FreeRTOS_7.0.1\include
13.05.2011 19:41:08 A----- 28.675 croutine.h
13.05.2011 19:41:08 A----- 3.755 data_model.h
13.05.2011 19:41:08 A----- 15.542 FreeRTOS.h
20.06.2011 12:53:07 A----- 7.183 FreeRTOSConfig.h
13.05.2011 19:41:08 A----- 13.201 list.h
13.05.2011 19:41:08 A----- 6.664 mpu_wrappers.h
13.05.2011 19:41:08 A----- 12.032 portable.h
13.05.2011 19:41:08 A----- 6.688 portmacro.h
13.05.2011 19:41:08 A----- 3.778 projdefs.h
13.05.2011 19:41:08 A----- 44.443 queue.h
13.05.2011 19:41:08 A----- 28.280 semphr.h
13.05.2011 19:41:08 A----- 8.832 StackMacros.h
13.05.2011 19:41:08 A----- 46.824 task.h
13.05.2011 19:41:08 A----- 44.520 timers.h


U:\IAR Projects\FreeRTOS_7.0.1\source
20.06.2011 12:45:10 A----- 15.156 croutine.c
20.06.2011 10:25:32 A----- 5.813 heap_1.c
20.06.2011 10:26:17 A----- 8.570 list.c
20.06.2011 12:30:44 A----- 1.976 main.c
20.06.2011 12:58:13 A----- 9.686 port.c
20.06.2011 10:26:19 A----- 5.585 portext.s43
20.06.2011 10:26:19 A----- 51.605 queue.c
20.06.2011 10:26:20 A----- 81.549 tasks.c”



So, what's the problem?

Regards, Vasiliy.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by Dave on June 20, 2011
Why don't you use the IAR project for the MSP430F5438 that is already in the FreeRTOS download?

You have not said what the "problem" is. You have said that you can compile the code and download it, which does not sound like a problem.

That said, you should not use printf() from more than one place without using mutual exclusion. I don't think that will work relliably even if printf() is directed somewhere. Where do you expect to see the text appear?

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 20, 2011
I don't use IAR project under Demo dir because it's created in newer version than my.

I used printf() just for test, and expect too see this text in "Terminal I/O", similiar with my previous test examples.

The problem is what when I create the task, the task code don't execute, in fact I don't see any code execution in Debug representation. For example, when I am trying to start simple "LED Blinking" software all work as expected.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by Richard on June 20, 2011
I can only support the latest versions of tools - or at least - the version I have. However, the MSP430X port is quite complex in that it is one port with several different configurations. You have to set parameters to say whether you are using large/medium/small code/data models, so you can see there are lots of permutations. The assembly code generated is different depending on the memory models, and the assembly code used in the FreeRTOS port layer has to be correct for the selected memory model. Trying to configure it yourself will not be easy without inspecting the port layer files to see how they determine which instructions should be used (the instructions used depending on the memory model used).

Regards.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 20, 2011
I setup the memory model in project settings options and in the FreeRTOSConfig.h


Can you make the similiar screenshots of your tools?

Regards.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by Richard on June 20, 2011
Projects are provided for all the different models, so there is a project with each of the radio options selected. The important thing is how this effects the automatically generated environment variables/preprocessor options, as can be seen by inspecting the data_model.h header file (FreeRTOS/Source/portable/IAR/MSP430X).

Does your version create __DATA_MODEL_SMALL__, __DATA_MODEL_MEDIUM__ and __DATA_MODEL_LARGE__ constants automatically? If no then you will have to define them manually.

Regards.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 20, 2011
Of course, I added this preprocessor directives into assembler options in the project settings, because without them I received compiler errors.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 21, 2011
Can you write me the full name of your controller, include revision? I think the problem is here.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by Richard on June 21, 2011
I just had a quick look but cannot find it right now, I think it must be in the other office. It is whatever is put on the experimenter board, REV C springs to mind, but I would have to check when I have the board in front of me.

Regards.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 21, 2011
Ok. In this time I found what the tick system does not work, because vApplicationIdleHook and vApplicationTickHook don't work(I placed in their body the LED light function).

Can you help me with this moment? The ticks code you can see on the top of the topic.

Thanks, Regards Vasiliy.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 21, 2011
Yeah! now it's work for me fine! But I don't know how I fixed this :( I think we problem was in the project settings, because my last action was modification project settings:
I checked "Data Model" radio button to "medium", and assembler preprocessor option too.

Very big thanks for help! regards, Vasiliy.

RE: FreeRTOS 7.0.1 + MSP430F5438 does not work

Posted by devfom on June 22, 2011
I'm still have problems.... In this time, when I'm writing the simple task, and put in their body LED on operators it's all OK, but when I add the vTaskDelay function this task works only 4 times.

Can you suggest me any kind of food for the thinking?

Regards, Vasiliy.


[ 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