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

FreeRTOS (NXP LPC1768) with RTC to throw an interrupt

Posted by lagavulin18 on June 1, 2014

Hi,

must something special be taken into account when using a RTC with FreeRTOS?

The code works fine without RTC. Once the RTC code is integrated to throw an alarm/interrupt, the system runs in a undefined state.

int main( void )
{
    // includes the RTC setup 
    prvSetupHardware();


    NVIC_DisableIRQ(RTC_IRQn);

    // C++ based xTaskCreate function
    pearlrt::t_TASK3.activate()

    NVIC_EnableIRQ(RTC_IRQn);


    // set RTC second to 0
    RTC_SetTime(LPC_RTC, RTC_TIMETYPE_SECOND, 0);

    // throw alarm/interrupt on second 10
    RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 10);

    /* Start the scheduler. */
    vTaskStartScheduler();

    /* IDLE task is used */

 }


// --------- prvSetupHardware() ------------------

void prvSetupHardware( void )
{
    [...]
    // Enable RTC
    init_RTC();
}

// --------- init_RTC()--------------------------

void init_RTC(void) 
{

   RTC_Init(LPC_RTC);

   NVIC_DisableIRQ(RTC_IRQn);
   NVIC_SetPriority(RTC_IRQn, ((0x01<<3)|0x01));

   RTC_Cmd(LPC_RTC, ENABLE);
   RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
   NVIC_EnableIRQ (RTC_IRQn);
 }

 // --------- RTC_IRQHandler() ---------------------

 void RTC_IRQHandler() 
 {
    if (RTC_GetIntPending(LPC_RTC, RTC_INT_ALARM))
    {
        debugMessage("Alarm");
        // Clear pending interrupt
        RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
    }

 }

FreeRTOS (NXP LPC1768) with RTC to throw an interrupt

Posted by jdurand on June 1, 2014

I don't see you setting the interrupt priority BEFORE enabling it.

Attachments

alternate (6245 bytes)

FreeRTOS (NXP LPC1768) with RTC to throw an interrupt

Posted by lagavulin18 on June 2, 2014

I was actually the opinion that the RTC must be reinitialized whenever the program (re-)starts but if I remove init_RTC() from prvSetupHardware(), everything works as expected. Reboot, reset the device, everything seems ok ... weird!


[ 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