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.

tms570ls1227 n2het

Other Parts Discussed in Thread: HALCOGEN

Hi,

With n2het instructions, for example SHFT, is it possible execute the instruction on two or more HET pins, simultaneously?

And with one instruction, is it possible capture the period of two HET pins, simultaneously?

thanks

  • Enrico,

    Essentially yes.   But this is how it happens. 

    1)  Inputs are sampled on each LR boundary

    2)  SHIFT instructions that execute during the loop use the captured samples of the pins.

    3)  You would in this case execute 2 SHIFT instructions each loop, one for each pin.

    4)  These two SHIFT instructions execute sequentially but the values that they shift in were *sampled* at the same time by the N2HET.

    5) Likewise, any SHIFT output is delayed until the next LR boundary.  So the outputs of both the shifts will appear on the pins simultaneously at the LR boundary, even though the execution of the SHIFT is sequential.

    Generally this is how HET works.  To get any input or output in between the LR boundary, we have the HR mode for some instructions and the HR field is the offset within the loop resolution (up to 7 bits...)

     

  • hi, Anthony,

    thank you for your reply.

    I'm a beginner with n2het and I would like to know if the program, which it is attached, can be realized with n2het.

     

    Thanks

    flow_n2het.pdf
  • Hi Enrico,

    Yes, this looks like something that HET can do.   You'll need to keep some sort of state and at the beginning of each loop test the state variable to see which part of the flow chart you currently need to be executing.  But that's easy enough to do.

    You will need to convert your flowchart to a state machine diagram.   I would go for an extended state machine diagram, i.e. a state diagram plus variables like loop counters.   Then try to minimize the # of states because you'll need an instruciton to branch to the state.

    For example the stretches of code like on page 3 where you have a pattern of 'set pins', delay, 'set pins' delay could be implemented by loading the pin value sequence into a set of 3 data words, and each time you hit the state either shift the data words out or decrement your 350us delay count.

    So looking at just page 3, you have

    Pin  HET[26] = {1, 1, 0, 1}

    Pin  HET[24] = {0, 1, 0, 1}

    Pin  HET[23] = {1, 0, 1, 0}

    With 350 us of delay in between.

    I'd try to compress everything on this page into a single state where while it's in the state it executed:

       loop 4 times: 

          is delay 0?

          If yes, then SHIFT pin 26,  SHIFT pin 24, and SHIFT pin 23,  and reset delay counter to 350 us.

          else decrement delay

        end of loop

    But before executing the above make sure you have preloaded the data fields of the shift instructions of pins 26, 24, and 23 to  680h  (1101b << 7)  pin 24 to 280h, and pin 23 to 500h.

    The above is something like two DJZ's, one for the 'loop  4 times' and the other for the 350us delay, with the 3 shift instructions embedded in the case where the inner loop resets to 350us.

    So probably 5 instructions to implement most of what's on page 3...  and the key is that you'd execute these same ones each HET loop that you're in this state.

    If you can organize the rest of your flow chart this way I think you'll find this is farily easy to do on HET.

  • Hi Anthony,

    Can you help me to starting with HET?

    how can I translate the following into a program HET?

    - preload the data fields of the shift instructions of pins 26, 24, and 23 to  680h  (1101b << 7)  pin 24 to 280h, and pin 23 to 500h

    - loop 4 times: 

          is delay 0?

          If yes, then SHIFT pin 26,  SHIFT pin 24, and SHIFT pin 23,  and reset delay counter to 350 us.

          else decrement delay

        end of loop

    Thanks

  • Enrico,

    Sure.  Are you familiar with the HET IDE?  If not then this is where I'd start.  There are a few tutorials included with the IDE and you should get comfortable running these.

    Once you're there,  the above might be more apparent.   But you can try this:

    Use the II  (Insert Instruction) and it will bring up a template for each instruction.

    The 'preload' steps would be 'MOV32' for the instruction.    The type would be IMTOREG&REM.  The preload value goes into 'data'.  the hr_data can be left blank because SHIFT operates on a 25 bit word and doesn't use the HR data field.  The reg can be NONE becuase you dont need to write the value to the reg.

    The remote field should be a label pointing to the SHIFT instruction that you want to preload.

    This is a quirk in the HET IDE.  If you have not yet entered the SHIFT instruction the label won't exist, and so you will get an error when you use the II tool because it will attempt to assemble each time you enter an instruciton.

    To get around this you can insert an '0' in the remote field of the wizard, then replace the 0 with the label for your shift instruction later.

    For example you might have instructions like this:

    OUTPIN1   .equ   0   ;Put your pin # here.  0 = N2HETx[0]

    PL1  MOV32 {remote=SH1, type=IMTOREG&REM, reg=NONE, data=500h, hr_data=0}

    SH1 SHFT {smode = or0, pin = OUTPIN1, cond=UNC, data=0}   ; Data=0 will be overwritten by PL1.

    This isn't a complete program though.  So try out some of the programs from the tutorials to get the basics down.

    For example you need to know that at the end of each execution the HET program must jump back to 00 before the HET loop resolution period ends, or else you wil get an overflow.

  • Hi Anthony,

    I'm quite familiar with HET IDE.

    I have difficulty to implement loop and delay function and a state machine.

    Thanks

  • Hi Anthony,

    Have you some examples to implement loop and delay function and a state machine?

    Thanks

  • Enrico,

    The easiest way to get a delay loop,  delay of 'N' loop resolution periods, is just to use the DJZ instruction.  You can experiment with this in HalCoGen, but basically you put the # of loops you want to delay into the data field.  DJZ will jump to one address while the data field is non-zero and another when it is zero. (if it's non-zero, it decrements the count).

    Try toggling a pin but put a DJZ in between toggles to insert a time delay.  If you can do that in the HET IDE you'll understand how to use it in your more complex program.

    For a state machine, you have to keep a state variable in memory.   At the beginning of each loop you can test the state value - which can be done with a SUB instruction followed by a BR.   i.e. to test for state=4 subtract 4 from your state value (you can discard the result, by saying dest=NONE, as you just want to set the flags).  Then you can use a BR with condition code = Z to jump to the code for state 4.  Of course you need a pair of these instructions for each state so it's relatively expensive and you should try to minimize the # of states you have.

  • Hi Anthony,

    thank you for your reply.

    I have a problem with the following instructions:

    IncTx CNT {reg=T,max=32,irq=OFF,data=0}; TxBit.data
    Tx BR {next=TxBitX,cond_addr=CurrSTAT,event=ZERO};

    TxBitX   AND { src1=T,src2=IMM,dest=NONE,data=0x1,hr_data=0};
    CheckNewData BR {next=Tx25,cond_addr=TxBit,event=ZERO}

    The jump to tx25 doesn't occured. Why?

    I try to create a sub-state machine that it simuletes the blink for 32 times.

    Regards

  • Hi Enrico

    enrico terraneo said:

    I have a problem with the following instructions:

    IncTx CNT {reg=T,max=32,irq=OFF,data=0}; TxBit.data
    Tx BR {next=TxBitX,cond_addr=CurrSTAT,event=ZERO};

    TxBitX   AND { src1=T,src2=IMM,dest=NONE,data=0x1,hr_data=0};
    CheckNewData BR {next=Tx25,cond_addr=TxBit,event=ZERO}

    The jump to tx25 doesn't occured. Why?

    So, you want to branch to Tx25 from CheckNewData on every even count value? (i.e. 0, 2, 4, ...?)

    I don't see why this would not work but can you tell me what the values of T, IMM are in TxBitX and what value the Z flag has after executing the AND instruction.   If it's not ever going to Tx25 then I would expect the Z flag is never set for some reason.   This would mean you'd only have odd count values.

  • Hi Anthony,

    I want to branch to Tx25 from CheckNewData on every odd count value and I want to branch to TxBit on every even count.

    How can I tell you what the values of T, IMM are in TxBitX and what value the Z flag has after executing the AND instruction?

    Thanks

  • Enrico

    See picture below.

    First, use the step button (1) to step up to and then past the AND instruction.  The arrow (2) shows you the next instruction to be executed.  So when it is on your AND instruction, this instruction will be next to execute but will not yet have executed...

    You can inspect the immediate data fields of all the instructions by viewing the memory (3).

    And the internal registers/flags are visible in (4).

  • Hi Anthony,

    I have the following problem, my het program starts when 1 is loaded in data of instruction 0.

    Enrico

  • Enrico,

    If that is a problem you can change it, but then I'd ask why you coded it that way.

    I can tell you that we often code programs that way to implement a 'start/stop' feature at the HET function level. 

     

  • Anthony,

    I have solved the both problems.

    First, I have changed the start of het program, now it starts without the test of instruction 0 data.

    Second, I have corrected the following instructions of het program:

    TxBit   SHFT { next=Master_Start,smode=OR0,prv=OFF,cond_addr=Master_Start,cond=UNC,pin=30,reg=NONE,irq=OFF,data=0x0};

    Tx25   SHFT { next=Master_Start,smode=OR0,prv=OFF,cond_addr=Master_Start,cond=UNC,pin=30,reg=NONE,irq=OFF,data=0x0};

    I had forgotten the conditional address parameter.

    Thanks for your support.

    Enrico