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.

64-bit N2HET counter



I'm having trouble implementing a simple 64-bit counter in N2HET.  The CNT and WCAP functions work fine, but the instructions below do not.  My init sets HETCGR = 0x30001 (IS=1, CMS=1, TO=1),  HETPFR=0x600, and HETPCR=5 (parity disabled).  I've manually reviewed my #defines and they appear to match the values in the reference manual, but here's what I see:

  • Problem #1: instruction[0] is supposed to put a 1 in register T, but instruction[1] always shows register T to be zero. (I capture register T correctly when I run a CNT operation on it, so I know the WCAP works).
  • Problem #2: instruction[2] doesn't change IMM data.  (e.g. even when I'm running a counter in the T register)
  • Problem #3: I expect instructions[0] and [1] to execute only once, but they seem to be running continously (based on HETADDR, which is always in the range [0..3] but usually reads zero on my emulator).
  • Problem #4: HETPAR = 4, but parity is disabled and I haven't written to that memory (this may be expected behavior; the emulator reads back HET RAM which I have not initialized)

I assume I'm doing something dumb, but can't figure it out.  Hope you can advise...

Thanks in advance,


Bill Naro

// SOURCE CODE FOR HET INSTRUCTION TABLE DEFNIITION:

static const PSP_TIME_HET_Instruction_T HET_64BIT_COUNTER_C[] =
{
    // initialization instructions

    // [0] : put 1 in register T, advance to next step
    {
        (PGM_ALU_D | PGM_NEXT_M(1u)),    // 0x2800
        (CTL_ALU_D | SUBOPCODE_ADD_D | SRC1_IMM_D | SRC2_ZERO_D | DEST_T_D), // 0x880024
        0x00000001u,
        0x00000000u
    },

    // [1] : capture register T (just to verify it was initialized properly), advance to next step
    {
        (PGM_WCAP_D | PGM_NEXT_M(2u)), // 0x5600
        (DEST_T_D), // 0x4
        0x00000000u,
        0x00000000u
    },

    // operation instructions - trying to run just these two instructions continuously...

    // [2] : increment 64-bit counter LSW by adding register T, advance to next step [3]
    {
        (PGM_ALU_D | PGM_NEXT_M(3u)), // 0x6800
        (CTL_ALU_D | SUBOPCODE_ADD_D | SRC1_IMM_D | SRC2_T_D | DEST_IMM_D), // 0x8E00A4
        0x00000000u,
        0x00000000u
    },

    // [3] : increment 64-bit counter MSW on LSW rollover by adding carry, jump back to previous step [2]
    {
        (PGM_ALU_D | PGM_NEXT_M(2u)), // 0x4800
        (CTL_ALU_D | SUBOPCODE_ADC_D | SRC1_IMM_D | SRC2_ZERO_D | DEST_IMM_D), // 0x18800A4
        0x00000000u,
        0x00000000u
    },

};
  • Hi Bill,

    Are you using the HET Assembler or the HET IDE, or is the code above the source that you are entering?

    If the latter, then I think the first thing to do is go to the HET IDE and enter the instructions in as assembly instructions, then use the assembler to convert them into the C function that you include into your program.

    Also you can debug in the HET IDE which is much easier than trying to debug on silicon.

    If you're already running your program through the HET assembler would it be possible for you to post the HET assembler source instead of the output?

     

  • The code was written here (a project requirement), but the values match those produced by the HET IDE using the following instructions:

    init1   ADD { src1=IMM,src2=ZERO,dest=T,data=0,hr_data=1};
    init2   WCAP { pin=0,event=NOCOND,reg=T,data=0};
    ctr1   ADD { src1=IMM,src2=T,dest=IMM,data=0};
    ctr2   ADC { src1=IMM,src2=ZERO,dest=IMM,next=ctr1,data=0};

    I'm unable to figure out the simulator, though. I can compile and load the project but all of the debugging command menu items (run, step, etc.) are disabled.  The "restart simulator" button appears to have no effect.

    I also tried to follow the tutorial instructions:

    4. Assemble or Build:
    5. Load HET Program
    6. Minimize SynaptiCAD window and highlight HET IDE
    7. Configure the signals to be viewed in the waveform using Waveform Wizard:

    but the "Waveform Wizard" and "Synapticad Wizard" menu items are also disabled.  Any helpful hints would be appreciated.

    Thanks,

    Bill

  • Hi Bill,

    Yes the HET IDE is in need of a new release;  it has compatability issues with newer versions of windows.

    There is a patch for the HET IDE attached here:

    https://e2e.ti.com/support/microcontrollers/hercules/int-hercules/f/365/t/314498.aspx

    If that doesn't help, try running HET IDE as administrator.  It seems to require administrator rights on Win 7.
    I have not been able to make the HET IDE run on Win 8 even in compatability mode.

    Regarding your code, would you please explain what the first two instructions are trying to do.

    ctr1 and ctr2 look ok.   But init1 looks like  'move #1 -> register T' and init2 looks like 'mov #1 to IMM' (because you are capturing register T which is always 1, and always doing this on every loop...).

    Also, this program will overflow,  because there is no path back to 0.  HET programs need to complete 1 cycle before the end of the loop resolution period (at latest) and branch back to address 0 in HET RAM.   The HET stalls there until the beginning of the next loop resolution period when it kicks the program off again.   This is how regular timing is maintained, independent of the length of your HET program (as long as it is one VCLK cycle less than a LRP). 

     

  • Thanks for your reply.

    I was able to get the HET running on silicon over the weekend but will download the HET IDE patch because we want to do more with it than the simple counter.  I'll also try running as administrator, but our IT folks make that difficult - we have to request the rights and are only granted it for a couple of hours at a time.

    Regarding your questions, item init2 was there just so see that item init1 was working, and I deleted it from my code when I got the timer running (it was failing due to a typo on my part).  Thanks for pointing out the overflow issue; I wasn't aware of that requirement and will modify my code to jump back to the first instruction instead of the second.

    I think we can close this issue, and thanks very much for your prompt help.

    Bill