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

MSP430 IAR Compiler - FreeRTOS issue

Posted by ammamon on March 11, 2011
I have written an rtc module for MSP430 device which captures date/time every one minute. This module uses freertos queue for sending the date/time event to another task. Though the time date-time details are captured every one minute, one or more of the details (either year, month, hour or ..) are getting corrupted depending upon whether the code optimization is set or not and whether the event object (ui_queue_event variable in the code below into which RTC time details are loaded ) is declared static or local in the interrupt function.

Actually there are 4 test cases.
1. Optimization set to none and time receiving event object declared local.
2. Optimization set to a value and time receiving event object declared local.
3. Optimization set to none and time receiving event object declared static.
4. Optimization set to a value and time receiving event object declared static.

The time data is corrupted consistently for each of the above 4 cases. In one case, it may be year corruption, in another case it may be hour corruption and so on. All the time details may be consistently correct for one of the cases. The pattern of corruption remained the same as long as the code is IAR compiled on a particular system. But if I compile the code in another system, the pattern of corruption for the above 4 cases differs. I tried compiling the code on 3 different systems running version 5.10.1.50144 of IAR MSP430 compiler.

Another point is the I am getting the "second" always as zero even when if I set it to a value during initialization of RTC module.

Can this be a stack problem? I am not getting any stack overflow error messages while debugging. Or is FreeRTOS creating problems here? Please help.

I am listing below the rtc code and the test code.

RTC Module code



#include "rtc.h"
#include "FreeRTOS.h"
#include "queue.h"

extern xQueueHandle ui_queue;

void rtc_set_date(rtc_date_struct_t *new_date)
{
RTCCTL01 = RTCMODE + RTCHOLD + RTCTEVIE + RTCTEV_0;
RTCYEAR = new_date->year;
RTCDOW = new_date->dow;
RTCMON = new_date->month;
RTCDAY = new_date->dom;
RTCHOUR = new_date->hour;
RTCMIN = new_date->min;
RTCSEC = new_date->sec;
RTCCTL01 &= ~RTCHOLD;
__enable_interrupt(); /* Sets GIE in status register */
}

#pragma vector=RTC_VECTOR
__interrupt void handle_rtc_interrupt(void)
{
ui_event_struct_t ui_queue_event;
__disable_interrupt();
switch(RTCIV)
{
case 2U: /* RTC Ready Event */
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

ui_queue_event.event_type = UI_QUEUE_EVENT_ONE_MIN_RTC;
ui_queue_event.year = RTCYEAR;
ui_queue_event.month = RTCMON;
ui_queue_event.dom = RTCDAY;
ui_queue_event.dow = RTCDOW;
ui_queue_event.hour = RTCHOUR;
ui_queue_event.minute = RTCMIN;
ui_queue_event.sec = RTCSEC;
RTCCTL01 |= RTCHOLD;
RTCCTL01 &= ~RTCRDYIE;
RTCCTL01 &= ~RTCHOLD;
__enable_interrupt();
xQueueSendFromISR(ui_queue, (void *) &ui_queue_event, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken)
{
portYIELD();
}
break;
}
case 4U: /* RTC Minute Interval Event */
{
RTCCTL01 |= RTCHOLD;
RTCCTL01 |= RTCRDYIE; /* Enable Ready Flag Interrupt */
RTCCTL01 &= ~RTCHOLD;
break;
}
default:
{
__no_operation(); /* For debugger */
break;
}
}
RTCIV &= 0x00U;
__enable_interrupt();
}


Test Code:


#include "msp430F5419.h"
#include "global.h"
#include "rtc.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include
#include

xQueueHandle ui_queue;
static void event_listener_ui_task (void * params);
static void ui_client_requests_task(void * params);


int16_t main(void)
{
WDTCTL = WDTPW + WDTHOLD;
ui_queue = xQueueCreate( 10, sizeof(ui_event_struct_t) );
xTaskCreate (ui_client_requests_task, (const signed portCHAR * const) "UI Client Requests Task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
xTaskCreate (event_listener_ui_task, (const signed portCHAR * const) "Event Listener UI Task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
vTaskStartScheduler();
return 0;

}

static void ui_client_requests_task( void * pvParameters )
{
static rtc_date_struct_t date;
date.year = 2011U;
date.month = 2U;
date.dom = 8U;
date.dow = 2U;
date.hour = 11U;
date.min = 16U;
date.sec = 30U;
rtc_set_date(&date);
while (1==1)
{
//infinite loop
}
}

static void event_listener_ui_task( void * pvParameters)
{
static ui_event_struct_t ui_queue_event;
while( 1==1)
{
portBASE_TYPE receive_status = xQueueReceive(ui_queue, &ui_queue_event, portMAX_DELAY);
assert(pdPASS == receive_status);
assert(ui_queue_event.event_type == UI_QUEUE_EVENT_ONE_MIN_RTC);
printf("%i,", ui_queue_event.year);
printf("%i,", ui_queue_event.dom);
printf("%i,", ui_queue_event.dow);
assert(ui_queue_event.year == 2011U);
assert(ui_queue_event.month == 2U);
assert(ui_queue_event.dom == 8U);
assert(ui_queue_event.dow == 2U);
printf("%i,", ui_queue_event.hour);
printf("%i,", ui_queue_event.minute);
printf("%i\n", ui_queue_event.sec);
}

}

RE: MSP430 IAR Compiler - FreeRTOS issue

Posted by Dave on March 11, 2011
Which MSP430 port are you using? The brand new MSP430X port, the old MSP430 port, or a third party one?

I don't know much about this one, but the thing that sticks out in your code is the manipulation of the interrupt enable bits in the interrupt itself. That is probably dangerous for a port that does not support nesting. In fact doing it that way would be dangerous for a port that does support nesting. Have you tried removing the disable and enable calls from the interrupt handler, all of them? The disable probably does nothing anyway, and the enables are the dangerous ones.

RE: MSP430 IAR Compiler - FreeRTOS issue

Posted by Dave on March 11, 2011
Also, check you have stack overflow checking switched on.


[ 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