Quality RTOS & Embedded Software

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


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