EmbDev.net

Forum: ARM programming with GCC/GNU tools ARM GCC newbie.IRQ and variables?


von Mhel M. (mhel)


Rate this post
useful
not useful
Hi, I've been trying to learn LPC2138 and GCC for a month now, thank to
the examples and docs provided by Martin the venture is not so
difficult.

I am using a homebuilt board, aside from lots of jumpers it seems to be
working well. It has taken a me good week to figure out how to use
interrupt with RTC, and finally it works. I'm having trouble with the
"rtcif" variable it seems never get changed. I am polling for rtcif in
main to reset it and turn LED5 off. The "tick" variable tho is ok since
I can see the blink on the other led1, but nothing on LED5. Can someone
explain to me what I'm doing wrong.

void rtcISR(void)
{
    ISR_ENTRY();
    if (rtcif==0)
    {
        rtcif=1;
        IO0SET = LED5_BIT;

    }
    if (tick==0)
    {
        tick=1;
        IO0CLR = LED1_BIT;
    }
    else
    {
        tick=0;
        IO0SET = LED1_BIT;
    }

    RTCILR = 1;     // Clear interrupt flag
    VICVectAddr = 0;     // Acknowledge Interrupt
    ISR_EXIT();   // recover registers and return
}

//globals
uint32_t volatile tick=0;
uint32_t volatile rtcif = 0;

RTCTime local_time,  current_time;

int main(void){
//system initialization here...
//set local_time here...

IO0SET = LED5_BIT;//LED5 off

    for (;;)
    {
        if (rtcif==1)
        {
            IO0CLR = LED5_BIT;
            rtcif=0;
        }
        current_time = RTCGetTime();
        //glcd_clearline(15);
        glcd_gotoxy(20,15);
        xprintf("%2u:%2u:%2u", current_time.RTC_Hour,
current_time.RTC_Min, current_time.RTC_Sec);

    } // for
return 0;
}

I added this in case it might help.

 44:rtcISR.c      ****     if (rtcif==0)
  26                r2, .L8
  27 0010 70209FE5     ldrh  r3, [r2, #0]
  28 0014 B030D2E1     cmp  r3, #0
  29 0018 000053E3     .loc 1 46 0
  45:rtcISR.c      ****     {
  46:rtcISR.c      ****         rtcif=1;
  30                eq  r3, #1  @ movhi
  31 001c 0130A003     streqh  r3, [r2, #0]  @ movhi
  32 0020 B030C201     .loc 1 47 0
  47:rtcISR.c      ****         IO0SET = LED5_BIT;
  33                req  r3, .L8+4
  34 0024 60309F05     moveq  r2, #-2147483648
  35 0028 0221A003     streq  r2, [r3, #4]
  36 002c 04208305     .loc 1 50 0
  48:rtcISR.c      ****
  49:rtcISR.c      ****     }
  50:rtcISR.c      ****     if (tick==0)
  37                  r2, .L8+8
  38 0030 58209FE5     ldr  r3, [r2, #0]
  39 0034 003092E5     cmp  r3, #0
  40 0038 000053E3     .loc 1 52 0
  51:rtcISR.c      ****     {
  52:rtcISR.c      ****         tick=1;
  41                eq  r3, r3, #1
  42 003c 01308302     .loc 1 57 0
  53:rtcISR.c      ****         IO0CLR = LED1_BIT;
  54:rtcISR.c      ****     }
  55:rtcISR.c      ****     else
  56:rtcISR.c      ****     {
  57:rtcISR.c      ****         tick=0;
  43                ovne  r3, #0
  44 0040 0030A013     .loc 1 52 0
  45                  streq  r3, [r2, #0]
  46 0044 00308205     .loc 1 57 0
  47                  strne  r3, [r2, #0]
  48 0048 00308215     .loc 1 53 0
  49                  ldreq  r3, .L8+4
  50 004c 38309F05     .loc 1 58 0
  58:rtcISR.c      ****         IO0SET = LED1_BIT;
  51                3, .L8+4
  52 0050 34309F15     .loc 1 53 0
  53                  moveq  r2, #134217728
  54 0054 0223A003     .loc 1 58 0
  55                  movne  r2, #134217728
  56 0058 0223A013     .loc 1 53 0
  57                  streq  r2, [r3, #12]
  58 005c 0C208305     .loc 1 58 0
  59                  strne  r2, [r3, #4]
  60 0060 04208315     .loc 1 62 0
  59:rtcISR.c      ****     }

von Mhel M. (mhel)


Rate this post
useful
not useful
I forgot to tell. I am using WinARM 2007113 testing.

von Clifford S. (clifford)


Rate this post
useful
not useful
What do you actually observe happening and how do you observe it?

It seems that as soon as rtcISR sets IO0SET = LED5_BIT, the main loop
will very quickly respond with IO0CLR = LED5_BIT such that you would
visually see no change in the LED.

If on the other hand you have used the debugger to observe that the
rtcif code in main() does not run, or you have seen with an oscilloscope
that there are no short pulses on LED5 then the problem is something
else (as well).

Clifford

von Mhel M. (mhel)


Rate this post
useful
not useful
Clifford,

Thanks for the reply. I'm still on the learning process, and obviously I
have to learn more.

You were right the changes is happening so quickly, that it appears
nothing is changing. I still have to learn how to use the debugger, I
can't figure out how to use it yet. I'm relying on my blinking led for
now.

I suspected that something like that was happening, since I know that
IRQ executes because of the other led, and the fact that if I commented
the section that resets the "rtcif" in the for loop and initialized LED5
to off then turn it ON in the IRQ it works. I just didn't think that a
short delay before I reset rtcif would show me visually that all is
well.

Thank you.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.