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.

RM57L843: GIO On-time measurement with RTI

Part Number: RM57L843
Other Parts Discussed in Thread: HALCOGEN

Dear TI,

I tried to measure the time of a GIO (N2HET) register with RTI timer-interrupt. I would like to measure 3 ms, so I configured the RTI Compare1 period to 0.01 ms in HALCoGen.

So the interrupt happens every 0.01 ms and there is a condition in which I inspect whether the GIO pin has 3.3V (ON-state) on it and I increase a variable with 0.01.

After then, I print out the measured on-times (it can be less or more than 3 ms, too), per second.

The problem is, that I measure 6ms which is the double of what it should be (3ms).

I attach the code snippet.

Any ideas, what can cause the problem?

Thanks for your reply in advance.

Regards,

Zsolt Nagy

The code snippet:

void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)

{

 if(notification == 2U){

       expt = gioGetBit(hetPORT1, 14);

        if(expt){

    milliseconds += 0.01;
}
}

  • Hello,

    Did you measure the accumulated time of "on state" in a specified period of time?
    1. ON(0.02ms)--OFF(0.05ms)--ON(0.05ms)--OFF(0.03ms)--ON(0.06ms): is the ON state is 0.02+0.05+0.06=0.13ms?

    If not, you need to reset millisecond to 0 if exp is not true.

    The vIH=2V, and vIL=0.8, please make sure the input voltage level is in the valid range.
  • Thanks for the fast reply. I think I measure it well, or, at least, the code is good. I attach the further parts of it (together with the former). What do you think? The problem persists. The GIO toggles are toggling a green LED if the signal is in a 2.8 - 3.2 ms range and a red LED, if it's not. Through debugging I was able to see that even the "milliseconds" variable gets filled with the wrong values, so the average calculation is bad, too.

    Thanks in advance.

    Regards,

    Zsolt Nagy

    The code snippet:

    void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)

    {

    if(notification == 2U){

    expt = gioGetBit(hetPORT1, 14);

    if(expt){

    stillactive = 1;
    milliseconds += 0.01;

    else if(stillactive){

    if(milliseconds>=2.8 && milliseconds <=3.2){

    gioSetBit(gioPORTA, 5, 0);
    gioSetBit(gioPORTA, 2, 1);
    }
    else {
    gioSetBit(gioPORTA, 5, 1);
    gioSetBit(gioPORTA, 2, 0);
    }
    stillactive = 0;
    msavg = (msavg + milliseconds) / 2;

    milliseconds = 0;

    }


    }

    }

  • And these are my HALCoGen settings, regarding the RTI.

  • Hello Zsolt,

    I will check for you
  • Hello Zsolt,

    If you still have the same issue with your code, I suggest to use NHET to measure the pulse width.

    NHET has one instruction called PCNT. PCNT detects the edges of the external signal at loop start and measures its period or pulse duration. If high resolution is used, the resolution is upto 10ns.

    Another instruction called ECNT can be used to count the edges of a stream of pulses (rising edge, or falling edge, or both).