This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL2-RM57L: How to LED Blink for using RTI function

Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: HALCOGEN

Hi guys.

i want to make LED Blink for using RTI function.

first, i've made LED for using "for" function

========================================

static int j=0;
void delay(void);
void delay(void)
{
for (j=0; j<10000000; j++);
}


int main(void)

{
gioInit();
rtiInit();

do{
gioSetBit(gioPORTB, 6, 1);
delay();
gioSetBit(gioPORTB, 6, 0);
delay();
}while(1);
}

but i want to make LED blink using RTI function for exact timing

i activated RTI function through Halcogen.

so i want to LED blink per 500ms.

COMPARE0 is 1ms setting.

how to make main code?

===========================HL_notification.c=================

void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)
{
 if(rtiNOTIFICATION_COMPARE0 == notification)
{
bspInit();
}

}
==========================================================

==========================main.c==========================
int time_count = 0;
void bspInit(void);
void bspInit(void)
{
if (++time_count > 500)
{
if(time_count > 1000)
{
if(++time_count > 1500)
{
time_count = 0;
}
else
{
gioSetBit(gioPORTB, 6, 1);
}
}
else
{
gioSetBit(gioPORTB, 6, 0);
}
}
}

int main(void)

{

gioInit();
rtiInit();

bspInit();

}

====================================================

  • Hi Junyoung,

    There is a LED blinky example in AHLCOGen Help topics. 

  • Hi QJ

    thank you for reply.

    this guide is very helpful for me.

    plus, i have more question.

    how to make longtime delay function.

    for example, i want to make below function

    1. LED1 blink ( 300ms turn on / off)

    2. 5sec delay

    3. LED2 blink ( on time 500ms / off time 1sec)

    in my think. i have to make delay function various , 300ms, 500ms, 1sec, 5sec

    RM57 have 4 rti compare mode, but i want to make only 1ms period using count function.

  • If you only use 1 RTI comparator, and have RTI interrupt every 1ms, you can a global variable to count the number of 1ms interrupts, and blink LED1 if count=300, etc.

    uint32 g_ulCount=0;

    void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)
    {

       g_ulCount++;

       if(g_ulCount = 300) {
           LED1_Blink;
       }

       if(g_ulCount = 500) {
           LED2_Blink;
       }

    }