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.

TMS570LS1224: Information from N2HET to CPU

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hello

I've been working on a project for a time now but I have been struggling with the N2HET. The project involves 11 DC motors with encoders, which are read with the N2HET module and a code I found here on the blog. I had some problems with that code, not being able to correctly read the edges (on the simulation) but apparently it was a problem with the simulated signals not being properly set. 

My problem now is that I haven't found how to actually read the information from the N2HET on the CPU. If im going to do a control over the motors, I need to read the information every X time. But I haven't been able to found some example of that...

I would really appreciate the help. 

Thanks and best regards

  • Hello Miguel,

    For motor control, the MCU needs to generate PWM signals, capture the impulse, and sample the ADC. For PWM, normally 3 instructions are used: counter (CNT), compare(ECMP etc), update (MOV32, MOV64, RADM64 etc). You can update the PWM period and duty cycle by write the data directly to the data field of update instruction (for example MOV32).

    The N2HET RAM is implemented as 4 banks of 96-bit wide two port RAM. This means that there a total of 8 ports available; four read and four write. Normally the N2HET will use up to two of these ports at a time. One read port is used to allow the N2HET to prefetch the next N2HET instruction while a write port may be used to update the data or control fields that have changed as a result of executing the current instruction.

    N2HET accesses to its own internal RAM are given priority over accesses from an external host (CPU or DMA), this makes N2HET program execution deterministic which is a critical requirement for a timer.

    Each N2HET instruction is 96-bits wide but aligned to a 128-bit boundary. Instructions consist of three 32-bit fields: Program, Control, and Data. If the MOV32 is the 3rd instruction of your code, you can access the data field by using:

    hetRAM->Instruction[3].Data

    HALCoGen generated a example code to get/write value from/to the NHET RAM, for example:

    pwmSetSignal(hetRAMBASE_t * hetRAM, uint32 pwm, hetSIGNAL_t signal);

    edgeGetCounter(hetRAMBASE_t * hetRAM, uint32 edge);

    ...etc

    You can call those functions in your RTI ISR. 

  • Hi Wang

    Thanks for your reply

    QJ Wang said:
    For motor control, the MCU needs to generate PWM signals, capture the impulse, and sample the ADC. For PWM, normally 3 instructions are used: counter (CNT), compare(ECMP etc), update (MOV32, MOV64, RADM64 etc). You can update the PWM period and duty cycle by write the data directly to the data field of update instruction (for example MOV32).

    Im using the EPWM module for the PWM generation. Im only missing the feedback to do the control. 

    If understand you correctly this line

    QJ Wang said:
    edgeGetCounter(hetRAMBASE_t * hetRAM, uint32 edge);

    I could use it to get the edges according to the name I give to each edge based on the RAM they are?  

    something like edgeGetCounter(hetRAMBASE_t * 1, uint32 encoder_1_a);?

    that way I would directly recover the actual data from encoder 1 channel A? 

    Thanks

  • Hi Miguel,

    Yes, you can use this function to read the counter. I prefer to write my own functions based on the NHET microcode and the header file generated through the NHET IDE.

    The header file (generated through HET IDE) defines variables for all the HET instrcutions. For example, pHET_START_0 points to the first instruction in my example code:

    If wanting to change the data field of the first instruction, we can use pHET_START_0 to access the start instruction: