This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debugging the LPC932 with EPM900

Hello!

Following problem. I intend to use the RTC of the LPC932 to create a delay function. Since it is a 23 bit counter it can count larger values to push the delay function from 1ms to 840ms using a 10 MHz crystal.
The code:

void delay (uint data cnt)
{
    RTCCON &= 0xFE;                 // clear RTCF
    RTCCON &= 0x7E;                 // disable RTC
    cnt = cnt * 78;                 // minimum 1msec
    if (cnt > 255) {                // load argument into RTCL and RTCH, both 8 bit
        RTCL = cnt - (cnt % 256);
        RTCH = cnt / 256;}
    else {
        RTCH = 0;
        RTCL = cnt;}
    RTCCON |= 1 ;                   // enable RTC
    while (!(RTCCON & 0x80));       // wait for counter to be 0, RTCF flag will tell

    RTCCON &= 0x7E;                    // disable RTC counter and clear RTCF flag;}

}

When running the code in the emulator, it keeps hanging at the while loop. When debugging step by step it keeps also hanging at the while loop and I can see in the peripherals window for RTC that both, RTCH and RTCL, are not set. Even if I step trough the if function, the command RTCH = cnt / (cnt % 256); does not set the SFR, while cnt is 0x302 at this point (memory watch).
-interrupts are disabled, I use only flags


Any clue?
TIA!

0