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.

Label of N2HET Program does not appear in C file

Other Parts Discussed in Thread: HALCOGEN

Hello,
I would like to see the N2HET Labels in C file.
Sometime it’s OK but sometime the labels are : /* hetlabel_0_0 */… with incremental numbers.
What can I do to always get the N2HET program labels ?
For example :
For this N2HET programme
pap1_AjPh_A  DJZ   {next=pap1_AjPh_B cond_addr=pap1_ChSi_A, reg=NONE, data=PHASE_Acc}   ;1C  Décalage du signal A pour créer la phase dans le sens positif.
pap1_ChSi_A  PWCNT {next=pap1_AjPh_B, control= ON, cond_addr= pap1_MdAc_Aa, hr_lr=LOW, en_pin_action = ON, pin= PA,action = SET, reg = T, irq=OFF, data= HDATA, hr_data = LDATA}    ;1C Changement d'état du signal PA
I got:
 /* hetlabel_0_0 */
 {
  0x00009480,
  0x00002006,
  0x00000000,
  0x00000000
 },

  /* hetlabel_1_0 */
 {
  0x000095C0,
  0x04405814,
  0x00001000,
  0x00000000

But I want:
 /* pap1_AjPh_A _0 */
 {
  0x00009480,
  0x00002006,
  0x00000000,
  0x00000000
 },

  /* pap1_ChSi_A _0 */
 {
  0x000095C0,
  0x04405814,
  0x00001000,
  0x00000000

Thanks a lot for your help
Kinds Regards
Jerome

  • Jerome,

    Honestly I never noticed that the comments in the .c file don't have the label.  I actually don't look at this file just use it by pointing HalCoGen at it for the copy to HET RAM.    So good feedback.

    I think the reason this is overlooked is that the .h file produced by the HET assembler is where all the 'action' is.  

    There is a struct there with each instruction and it's label when applicable.  

    For example:

    ...
    
    typedef union
    
    {
    
    HET_MEMORY Memory1_PST[35];
    
    struct
    
    {
    
    SUB_INSTRUCTION STARTPWM_1;
    
    BR_INSTRUCTION hetlabel_12_1;
    
    ADD_INSTRUCTION hetlabel_13_1;
    
    MOV64_INSTRUCTION hetlabel_14_1;
    
    ADD_INSTRUCTION hetlabel_15_1;
    
    CNT_INSTRUCTION TBASE1_1;
    
    ECMP_INSTRUCTION PERPIN_1;
    
    MOV64_INSTRUCTION PERSET_1;
    
    MOV64_INSTRUCTION PERCLR_1;
    
    ADD_INSTRUCTION BUFPER_1;
    
    ADD_INSTRUCTION BUFDCA_1;
    
    MOV32_INSTRUCTION CURPER_1;
    
    ADD_INSTRUCTION hetlabel_23_1;
    
    ADD_INSTRUCTION hetlabel_24_1;
    
    SUB_INSTRUCTION hetlabel_25_1;
    
    SUB_INSTRUCTION hetlabel_26_1;
    
    MOV32_INSTRUCTION hetlabel_28_1;
    
    ...

    The lines in this above snip that have 'hetlabel' are just lines I didn't put a label on explictly in the assembler (.het file) otherwise the rest of the lines match labels from the HET assembler file:

    PHAHI       .equ     0
    
    PEROUT      .equ     4
    
    PHAHI_SH    .equ    (PHAHI + 1)
    
    cntmax      .equ    0FFFFFFFFh
    
    cntmax_lr   .equ    (cntmax / 128)
    
    defper  .equ    6DAh
    
    defdca  .equ    000h
    
    per_lr  .equ    (defper / 128)
    
    dca_lr  .equ    (defdca / 128)
    
    per_hr  .equ    (defper % 128)
    
    dca_hr  .equ    (defdca % 128)
    
    STARTPWM  SUB   {src1 = IMM, src2 = ZERO, dest=NONE, data=0, hr_data=0}
    
       BR    {event=NZ, cond_addr= TBASE1}
    
       ADD   {src1 = IMM, src2=ZERO, dest=T, rdest=REM, remote=TBASE1, data=1FFFFFFh, hr_data=0}
    
       MOV64 {en_pin_action=ON,  reg=T, pin=PEROUT, action=CLEAR, data=0, hr_data=0, cond_addr=PERSET, remote=PERPIN, comp_mode=ECMP}
    
       ADD   {src1 = ZERO, src2=ZERO, dest=NONE, rdest=REM, data=0, hr_data=0, remote=PERCLR, next=AHIONINIT}
    
    TBASE1    CNT   { comp=GE, reg=T, max=cntmax_lr, data=1FFFFFFh};
    
    PERPIN    ECMP   {en_pin_action=ON,  reg=T, pin=PEROUT, action=CLEAR, data=0, hr_data=0, cond_addr=PERSET, hr_lr=high, next=PWMPINS};
    
    PERSET    MOV64 {en_pin_action=ON,  reg=T, pin=PEROUT, action=SET,   data=0, hr_data=0, cond_addr=PERCLR, remote=PERPIN, comp_mode=ECMP, next=BUFPER};
    
    PERCLR    MOV64 {en_pin_action=ON,  reg=T, pin=PEROUT, action=CLEAR, data=0, hr_data=0, cond_addr=PERSET, remote=PERPIN, comp_mode=ECMP, next=HPUPDATES};
    
    ; Update PWM switching points for next period.   This code jumps around a lot;
    
    ; the reason is to keep BUFPER, BUFDCA, BUFDCB, BUFDCC together for the CPU to write to
    
    ; as a block of data values.
    
    BUFPER    ADD {src1 = IMM, src2 = ZERO, dest=S, data=per_lr, hr_data=per_hr, next=CURPER}
    
    BUFDCA    ADD {src1 = IMM, src2 = ZERO, dest=R, data=dca_lr, hr_data=dca_hr, next=PHASEA}
    
         ; The following could be optimized out, if the period change is always done statically with the NHET PWMs off.
    
         ; Code below allows period to be updated on the fly by writing to BUFPER.  Calculates half-period update point dynamically.
    
    CURPER  MOV32 {type=REGTOREM, reg=T, remote=CURPER};
    
       ADD   {src1=T, src2=S, dest=T, rdest=REM, data=0, hr_data=0, remote=PERCLR}  ; S = Period,  T = SONP and write this to PERCLR
    
       ADD   {src1=S, src2=ZERO, dest=R, data=0, hr_data=0, smode=LSR, scount=1}    ; R = Period / 2
    
       SUB   {src1=T, src2=IMM, dest=T, data=1, hr_data=0}                  ; Half Period Compare needs to be a loop res before actual half.
    
       SUB   {src1=T, src2=R, dest=NONE, rdest=REM, data=0, hr_data=0, remote=PERPIN, next=BUFDCA} ; Write Half Period Compare to PERPIN

    In the .h file, the instructions are given types like SUB_INSTRUCTION that are specified in the 'std_nhet.h' file.

    So if you create a watch window entry, pointing at your HET program and casting it with the type   HETPROGRAM0_UN  or the like that is created in the .het file, then I think you actually can in CCS's watch window get a nice view of your HET program as it is in memory,  and decomposed by instruction type into the various fields.   Much nicer to work with than that .C file with just hex digits.. 

    Best Regards,

    Anthony

  • Dear Anthony,

    Thanks a lot for your reply and your explanations.

    There are two reasons for which I’m looking at the N2HET .C file.

    The first reason is to copy a control field of an instruction then to paste it in another instruction. For example:

    pap1_AjPh_A  DJZ   {next=pap1_AjPh_B cond_addr=pap1_ChSi_A, reg=NONE, data=PHASE_Acc}

    ……

    pap1_AjAcc  DADM64{remote=pap1_AjPh_A, data=V_Acc12,hr_data=0, cntl_val=0x00002006}            

    The control field of the instruction: “pap1_AjPh_A” can change if I insert a new instruction in the program because the Conditional address of the DJZ is in the control field.

    In this case it’s easier to find the control field of the “pap1_AjPh_A  DJZ “ instruction with the label.

     The second reason is that I write the application program in assembly language instead of C language. I use also HalCoGen for initialization part, after, the program is in assembly-only project.

    Transform the h.file to make assembly declarations is one possibility.

    But have you suggestions to integrate N2HET labels in assembly .ass file?

    Thanks for your help.

    Jerome

  • Hi Jerome,

    If you put a label on every line in the HET program that your host CPU driver needs to interact with,

    for example any instruction that you want to modify the control field of through the Cortex R;  then everything you need should be in the header file.   

    Here's some test programs I was recently working on:

    3288.het_pcnt_tests.zip

    7635.N2HET_ERRATA_CHECK_CHAMP_PGE.zip

    Here are some lines from 'sys_main.c' where I'm changing the program field (to change the type (R2F, F2R, etc..) and the Pin#) of PCNT instructions and the control filed (to change similar options) of WCAP instructions:

    					pPC1->Program = ((pPC1->Program) & 0xFFFFFF00U) | (pc1_types[test])<<6 | pc1_pins[test];
    					pPC2->Program = ((pPC2->Program) & 0xFFFFFF00U) | (pc2_types[test])<<6 | pc2_pins[test];
    					pWC1->Control = ((pWC1->Control) & 0xFFFFE09FU) | (wc1_types[test])<<5 | wc1_pins[test] << 8;
    					pWC2->Control = ((pWC2->Control) & 0xFFFFE09FU) | (wc2_types[test])<<5 | wc2_pins[test] << 8;
    

    now, pPC1 is:

    hetINSTRUCTION_t *pPC1    = &(hetRAM1->Instruction[pHET_PC1_0]);
    

    (also in sys_main.c) but hetINSTRUCTION_t comes from HalCoGen's reg_het.h and pHET_PC1_0 is generated in the .h file created by the het assembler... 

  • Thanks a lot for your examples and explanations.

    I will use the .h file now; it’s certainly a better practice.

    Kind Regards