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.

NHET Loop back mode in HET Simulator

Hi,

I want to use nHET[0] to output a PWM, and use nHET[1] as input to detect nHET[0]'s output PWM.
According to TRM "Literature Number: SPNU489B",in section "18.4.5.6 Loop Back Mode".
In HET simulator,I set :HET clock frequency=80MHz, HR=1,LR=128;
then set these two registers: NHETLBPSEL=0x00000001,NHETLBPDIR=0x000A0001;
and then click "assemble and load" from "Debug" menu, but it seems the loop back mode doesn't work.
The instrutions i used are following:
A_MAXC      .equ  9 ; PWM period value
A_INVE      .equ  6  ; PWM pulse invert value
A_HRVAL      .equ  0 

; Simple PWM
L00 CNT   {  reg=T, irq=OFF, max= A_MAXC }
L01 ECMP {  en_pin_action=ON, pin=0, action=PULSEHI, reg=T, data= A_INVE, hr_data=A_HRVAL}
C00   WCAPE { pin=1,event=FALL,reg=T,ts_data=0,ec_data=0};
L02 BR      { next= L00, cond_addr=L00, event= NOCOND }

Could you please tell me what's wrong? Thanks very much.

  • Hi Fumin,

    There's a pretty good chance that this feature isn't modeled, because it's IODFT which is more of a test function rather than a functional mode.  Our objectives for developing the NHET simulator tool were more to help with programming of application code.   Now maybe we should be considering IODFT as a functional mode for this product given it's a safety device;  would be good to get your input on how imprortant it is to have this in the simulator.

    The other possibility might be that it's due to the IO buffer being left out of the model - 'analog' loopback would need to go out through the output buffer and come back into the input buffer.   You can see the IO buffer isn't included because in the simulation trace there are separate bus ports for the HET data out and HET data in.  If this were the case I think there might be something you could do by upgrading the Synapticad tool to one which allows for reactive test benching - but it looks like you've got digital loopback selected so I doubt this is the issue.   Most likely IODFT is just not included in the model.

    The engineer in charge of the NHET simulator and system-c model development is out of the office today but I'll shoot him an email and see if he can answer definitively.

    In the meantime - you might try this particular code on silicon if you've got it available.

    Thanks and Best Regards,

    Anthony

  • I run this program on development board, but it still not works. Could you please tell me what's wrong with it? Does NHET module is not support this loop back mode?

    And if i want to use nHET[0] to output a PWM, and use nHET[1] to capture this PWM (by WCAPE instruction), can i directly connect the nHET[1] with nHET[1]  by wire on the development board?

    In C code, My configuration are following:

    void OCHET_InitSync(void)
    {

        if ((hetREG->GCR & 0x1) == 0)
        {
         memcpy((void *) &e_HETPROGRAM1_UN, (const void *) HET_INIT1_PST, sizeof(HET_INIT1_PST));
         /* initalise HET0 module */
         hetREG->PFR     = 0x00000700U; // Prescaler Configuration (HR=1, LR=128 => TS=128)
         hetREG->DOUT    = 0x00000000U; // Output 0 to shut down the MOS FET
         hetREG->DIR     = 0xFFFFFFF1U; // pin0:output, pin1:input
         hetREG->LBPSEL     = 0x00000001U;
         hetREG->LBPDIR     = 0x000A0001U;

         }
     }

    after this intialization, In my main function, i use the following code to read the WCAPE datafield value, but these code can't be executed.

    static portSTACK_TYPE time_stamp=0x00;
    static portCHAR edge_counter=0x00;
    static portCHAR step=0x01;

    void main(void)
    {
    /* USER CODE BEGIN (3) */

     OCHET_InitSync();
       
      //period=(624+1)*LRP=625*1.6us=1ms
      HET_L00_1.memory.control_word = 624;
      // Start HET: Ignore suspend; NHET is master;Turn NHET on
      hetREG->GCR    = 0x00030001U;
         while(1)
        {
         if((HET_C00_1.memory.data_word)&0x7F == (edge_counter+step))
          {
           time_stamp = (HET_C00_1.memory.data_word)<<7;
          edge_counter = (HET_C00_1.memory.data_word)&0x7F;
          }          
        }
       
    /* USER CODE END */
    }

  • yes you can connect nHET[0] with nHET[1]  by wire on the board if you take care about the pin input and output settings.

    hetREG->DIR     = 0xFFFFFFF1U; // pin0:output, pin1:input

    But in your NHET program you need two CNT instructions:

    L00 which allows to set the period of your test PWM on pin 0 (with the max parameter).

    L02 which provides a free running counter in register T which is captured to WCAP_DF[31:7] after a falling edge on pin 1.

    So L00+L01 generate the test signal on pin 0 and L02+L03 handle the input signal on pin 1.

    For L02+L03 you can also use register A or B.

     

    L00   CNT    {  reg=T, irq=OFF, max= A_MAXC }

    L01   ECMP {  en_pin_action=ON, pin=0, action=PULSEHI, reg=T, data= A_INVE, hr_data=A_HRVAL}

    L02   CNT       {  reg=T, irq=OFF, max= 0x1FFFFFF }

    L03   WCAPE { pin=1,event=FALL, reg=T, ts_data=0, ec_data=0};

    L04   BR         { next= L00, cond_addr=L00, event= NOCOND }

     

    In your CPU code you should read all 32 bit of the WCAPE data field in one access

          value = HET_L03_1.memory.data_word;

     and then mask out the time stamp and edge counter part

           time_stamp = value >>7;

          edge_counter = value & 0x7F;

    It is important that the 32 bit data field of WCAPE  is read in one CPU load instruction.

    If not there could be the problem that the NHET data field is updated by the NHET (caused by a new edge) between two CPU reads resulting in not consistent time stamp and edge counter data.