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 PWM example

Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm followig the "NHET getting started" but cannot compile the required code.

My . het program compile flawless using "hetp.exe -no -hc32":

  L00: CNT{next = L01, reg = A, max = 624}
  L01: MCMP{next = L00,
          reg = A,
          en_pin_action = ON,
          hr_lr=HIGH,
          pin = CC0,
          action = PULSEHI,
          order = REG_GE_DATA,
          data = 0x1D4,
          hr_data = 0x60
          }

That's generated .h:

  #ifndef __PWM_test_h
  #define __PWM_test_h

  #define HET_L00_0    (e_HETPROGRAM0_UN.Program0_ST.L00_0)
  #define pHET_L00_0      0

  #define HET_L01_0    (e_HETPROGRAM0_UN.Program0_ST.L01_0)
  #define pHET_L01_0      1


  typedef union
  {
     HET_MEMORY    Memory0_PST[2];
    struct
    {
        CNT_INSTRUCTION L00_0;
        MCMP_INSTRUCTION L01_0;
    } Program0_ST;

  } HETPROGRAM0_UN;

  extern volatile HETPROGRAM0_UN e_HETPROGRAM0_UN;

  extern const HET_MEMORY HET_INIT0_PST[2];

  #endif

And that's .c:

  //#include "std_het.h"
  #include "std_nhet.h" // FIXME

  HET_MEMORY const HET_INIT0_PST[2] =
  {

     /* L00_0 */
    {
        0x00002C20,
        0x00000270,
        0x00000000,
        0x00000000
    },

     /* L01_0 */
    {
        0x00000000,
        0x00404058,
        0x0000EA60,
        0x00000000
    }
  };

As you can see I've corrected "std_het" with std_nhet" here. Can this be done other than by hand?

When I include .h in my sys_main.c and add .c to compilation these errors are generated:

"C:/Documents and Settings/guest0/Documenti/workspace_CSSv5/TMS570HDK_NHET_PWM_EXAMPLE/NHET/PWM_test.h", line 14: error #20: identifier "HET_MEMORY" is undefined

"C:/Documents and Settings/guest0/Documenti/workspace_CSSv5/TMS570HDK_NHET_PWM_EXAMPLE/NHET/PWM_test.h", line 17: error #20: identifier "CNT_INSTRUCTION" is undefined
>> Compilation failure
"C:/Documents and Settings/guest0/Documenti/workspace_CSSv5/TMS570HDK_NHET_PWM_EXAMPLE/NHET/PWM_test.h", line 18: error #20: identifier "MCMP_INSTRUCTION" is undefined
"C:/Documents and Settings/guest0/Documenti/workspace_CSSv5/TMS570HDK_NHET_PWM_EXAMPLE/NHET/PWM_test.h", line 25: error #20: identifier "HET_MEMORY" is undefined

And seems right because the -c does not include nothing so I cannot know where the above defines should be defined.

Do I miss something?

Thank you

  • Matteo,

    It looks to me like the macros from std_nhet.h are needed in the PWM_test.h but you included std_nhet.h in your c progam.

    So if you include std_nhet.h after PWM_test.h you would get these type of errors; you might just switch the order.

    There might be an easier way if you use HalCoGen though.   If you have a HalCoGen project, you can select a custom HET program like this:

    I've never had trouble building this way when the .c and .h I insert come from the HET IDE.

    I say the HET IDE but hetp is OK,  however you might need the -v2 option on the command line if you are targetting N2HET.   If you build through HET IDE and select the correct part # it will take care of getting the command line right for you.

     

     

  • Antony,

    Even if I add the -v2 option to the netp command the included file is "std_het.h" instead of the right one "std_nhet". Using the command line compiler the only solution seems to modify the right include by hand.

    As you pointed out Including "std_nhet.h" before my header in sys_main resolve the undefine-errors in the assembler-generated header. Nevertheless I consider this a (minor) assembler failure because the generated c-code files are not self consistent.

    Surprisingly assembling the program inside the HET IDE resolved both problems.I'd be curious to know how the assembler command is built into the HET IDE...

    Another thing i don't understand is why the HET device number (option -nX for the command line assembler) is NOT required while building the HET IDE project, nevertheless the generated code is the same. How do the HET IDE knows this information?

  • Matteo,

    There is HETDeviceDefinitions.xml file that has the build options included.

    I tried a moment ago building on the command line:

    C:\Users\a0321811\workspace_v5_4\hwag_proj1\hwag_proj1_het>hetp -hc32 -v2 -n0 hwag_proj1_het.het

    And the file that is included in the output .c file is std_nhet.h, not std_het.h.

    Are you using something different on the command line?

     

  • Problem solved: on command line I was using the 1.4 version (from a previous standalone installation) while the NHET IDE uses the 1.7. The latter works as expected in command line too.

    And what about the device number? How NHET IDE knows this information if is not required inside the MMI?

  • Hi Matteo.

    What's the MMI?

    In the IDE - when you create a project you pick the device number.  Based on the device number the IDE knows (through XML files) which version of HET, NHET, N2HET to use and how many pins are available, etc..

     

  • Hi Antony,

    whith MMI I mean the IDE interface. I'm running the HET IDE v3.3 and when I create a new project only the device and the clock frequency are required. I don't understand how the IDE knows wich device number must be used. Using the command line compiler this information is given throught the -nX option.

    BTW I don't understand why this option is required by the command line compiler seeing that the required device is set in the C code when loading the program in the HET RAM (I mean: if I assemble the code with -n0 can I load and run it in the HET2?).

    Matteo