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.

N2HET: Behaviour of ECNT instruction which is not executed in every LRC

Hi.

My question is regarding the N2HET module, of the TMS570LS31x.

I have the following N2HET program:

; The Data Field of the DJZ could be written by a separate C-function with the
; value 1.
; If this C-function is     called the I01:ECNT will NOT be executed.
; If this C-function is NOT called the I01:ECNT will     be executed.
U01: DJZ   { next = I02, reg = NONE, cond_addr = I01, data = 0 }
; Execution of this ECNT depends on previous U01:DJZ.
I01: ECNT  { next = I02, cond_addr = I02, pin = 9, reg = A, event = RISE, data = 0 }
; Some further instruction.
I02: MOV32 {...}

So if I01:ECNT will be executed in one LRC (= Loop Resolution Cycle) depends if the separate C-function is called or not.

Now assume the following situation:

  1. During the LRC x, the Data Field of the ECNT instruction is 5.
  2. During the LRC x+1, pin 9 detects a rising edge.
  3. Also during the LRC x+1, the separate C-function will be called.
  4. During the LRC x+2, the ECNT instruction will NOT be executed (cause the C-function was called). So the Data Field of the ECNT will stay at 5.
  5. During the LRC x+3, the ECNT instruction will be executed again. Question: Will now the Data Field of the ECNT be incremented to 6, cause of the rising edge in LRC x+1?

My assumption is that during the execution of LRC x+3, the Data Field of the ECNT will stay at 5. Can you confirm this assumption?

Thank you and regards

Oliver.

  • Hello Oliver,

    I have forwarded you question to one of our experts and they will respond soon.

  • Oliver,

    Since the timing here could be very critical I'll try to answer what I think is the basis of your question rather than the answer to the exact scenario presented.

    The ECNT relies on an edge detection that samples the pin at loop resolution clock period boundaries and detects either a rising or falling edge based on the change in the pin from one loop resolution clock to the next.

    So let's say the pin is  low, low, high, high  when sampled during four consequitive loop resolution periods.

    The rising edge detect that the ECNT instruction uses is only going to be active for that first loop where the pin has changed from low to high.   If you disable the ECNT there, and enable it in the 2nd loop,  during that 2nd loop the ECNT instruction is not going to see a rising edge because the pin is high, and it was high when sampled at the previous loop boundary.   

    Therefore in the general sense I think your answer is right - the ECNT will remain at '5'.   But if you want to get very precise about the timing of this scenario - i.e. when the write to the DJZ has to happen with respect to the pin edge taking into account the delays of the N2HET,  I'd suggest simulating the case with the HET IDE.


     

  • Anthony,

    as always thank you for the really fast response. You also get the basis of my question correctly.

    Regarding the timing: Yes I'm aware that the timing could be in such cases very critical. But for this example timing is not of major concern. More important is the behavior of the ECNT instruction in case it is not executed. And this was answered by you.

    Thank you and regards

    Oliver.