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.

A N2HET program is OK in simulation with HET IDE but is NOT OK when using RM48 USB Stick Development Kit.



The following program works in simulation with HET IDE but does not work when using RM48 USB Stick Development Kit.
The problem is: there are no pulses on pin 1.
There are no errors when compiling, loading and executing the programs.

;---------------------------------------------------------------------------------------------------------
; METHOD WHICH INCLUDES THE INSTRUCTIONS ADD, DADM64  ET MOV64 V 2.0
;---------------------------------------------------------------------------------------------------------

;This Method produces pulses with a length from the LengthMini value to LengthMAxi value by step of LengthStep
;The values of  LengthMAxi , LengthMini are fixed to 10 and 6 to run the program in  step by step with HET IDE
;In production these values are more important  :  period = 200 LengthMAxi =180, LengthMini = 1 LengthStep = 2.
;The execution of the program take a maximum of 5 cycles.
;The signal frequency must be near of 5 Khz
;----------------------------------------------------------------------------------------------------------------------------

Sign_period .Equ 200 ; Signal Period : = 200 In Production 10 in simulation
LengthMAxi .Equ 180 ; LengthMAxi : = 180 In Production 6 in simulation
LengthMini .Equ 1 ; LengthMini : = 1   In Production 1  in simulation, minimum value = 1 ==> 2 Loop cycles
LengthStep .Equ 1 ; LengthStep : = 1   In Production 1  in simulation

noPinA  .Equ 1 ; Numéro de la pin A

L01    CNT   {brk=ON, reg=A, irq=OFF, max = Sign_period, data=0} ;1c
L02    ECMP  {cond_addr= L04, hr_lr=HIGH,en_pin_action=ON,pin=noPinA,action=PULSEHI,reg=A,irq=OFF,data=LengthMini,hr_data = 0x0 };1C
L03    BR    {next=L05, cond_addr=L01, event=NE} ;1C 
L04    ADD   {next=L01, src1=A, src2=ZERO, dest=B, data=0, hr_data=0} ; Reg B = Reg A 1c
L05    ECMP  {cond_addr= L07,hr_lr=LOW,en_pin_action=OFF,pin=0,action=CLEAR,reg=B,irq=OFF,data=LengthMAxi,hr_data = 0x0 };1C
L06    DADM64{next=L01,remote=L02, data=LengthStep,hr_data=0, cond_addr= L04,comp_mode=ECMP, en_pin_action=ON,pin=noPinA,action=PULSEHI,reg=A,irq=OFF }  ; Length=Length+LengthStep ;1C
L07    MOV64 {next=L01,remote=L02, data=LengthMini,hr_data=0, cond_addr= L04,comp_mode=ECMP, en_pin_action=ON,pin=noPinA,action=PULSEHI,reg=A,irq=OFF }  ;pulse Length =LengthMini ; 1c

If I just replace the program with the following program the execution is correct.
I did not change anything else.
But i need to install the first program more sophisticated.

;------------------------------------------------------------------------------------
; METHOD WHICH INCLUDES THE INSTRUCTIONS ADD, ET MOV32
;------------------------------------------------------------------------------------

;This Method produces pulses with a length from the 1% to 100% of the signal period value
;The values of  LengthMAxi , LengthMini are fixed to 10 and 6 to run the program in  step by step with HET IDE
;In production this value = 200.
;The execution of the program take a maximum of 8 cycles.
;The signal frequency must be near of 5 Khz
;----------------------------------------------------------------------------------------------------------------------------

EnableLgnt .Equ 200 ; EnableLgnt : = 100 In Production 20 in simulation
noPinA  .Equ 1 ; Numéro de la pin A

L01    CNT   {reg=A, irq=OFF, max = EnableLgnt} ;1c
L02    ECMP  {next=L01,cond_addr= L03,hr_lr=LOW,en_pin_action=ON,pin=noPinA,action=PULSELO,reg=A,irq=OFF,data=EnableLgnt,hr_data = 0x0 };1C
L03    ADD   {next=L04, src1=A, src2=ONES, dest=B, data=0, hr_data=0} ; A-1 dans data de L01 1c
L04    BR    {cond_addr=L06, event=C} ;1C
L05    MOV32 {type=IMTOREG, reg=B, data=EnableLgnt, hr_data=0 } ; reg B = EnableLgnt 1C l'algorithme est decroissant 2C
L06    MOV32 {next=L01, remote=L02, type=REGTOREM, reg=B, data=0, hr_data=0 } ; datafield L02 = reg B : 2C

Thanks a lot for your help

Kind Regards

  • Hi,
    Just a few notes as we have been using N2HET quite a lot lately:

    1. Make sure you have the IO pin set as an output.
    2. Your program may need a branch to instruction 0 at the end of it (I think this was written in the TRM as a requirement of N2HET)
    3. Remember that if you are supply data fields to your N2HET program then the HR data is the first 7 bits of most data fields, so you need to shift the values accordingly. In N2HET simulation data and hr_data are separate fields.
    4. You can set the 'break' bit of most instructions 1 to to ensure the N2HET program execution is correct (i.e. if you are DJZ, etc.)

    5. MOV64 instructions also overwrite the control word of the target instruction.

    Cheers
    Stomp!.

  • Thanks Stomp.

    Can you pls check the first 2 bullets from stomp's post on making sure the I/O is configured and you have an instruction to wrap around in the end. Or you can try a simpler PWM to be output on pin1 before getting in to this as well.
  • Hello Jerome,

      One more thing to check is that the first instruction L01 CNT you have brk=ON. This means that in real silicon the instruction will assert a debug request to the CPU and hence halt the CPU. Is this what you are seeing on the silicon?

  • Hi,
    Thanks very much for your fast replies and good explanations.
    For the branch to instruction 0 I prefer include it to the last instruction to save a cycle.
    Is that a good practice?
    The problem came from BRK=ON. Excuse me for that mistake.
    All is working very well now.

    Kind regards

    Jerome

  • Hello Jerome, Glad that the problem is solved with the BRK disabled.
    Not clear about the BR instruction to the end of the program. Currently, you don't have such BR instruction at the end of the program. What you have is a MOV64 with the next address equal to the first instruction in the program which is fine. You could add a BR at the end of the program where the MOV64 before it will have the next address equal to the BR instruction address. The BR will have both the next and cond_addr set to the beginning of the program. Either way is fine.