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.

Generate and monitor pwm pulses het ide

Other Parts Discussed in Thread: TMS570LS1227, HALCOGEN

Hi,

I am using the TMS570LS1227.

 

I am trying to use the het ide, but I am having trouble monitoring the pulses I an generating.

I am successfully generating three pulses:

pulse 1 - freq 853 kHz, DC 50%; pulse 2 - freq 640 kHz, DC 50%, pulse 3 - freq 512 kHz, DC 20%.

These pulses are being generated using pins 0,2,4.  They are then routed back in on pins 6, 8, 10.

 

When I try to read the period and duty cycle in my code (right now only trying to read for pulse 1) through the PCNT register, I always read 0.  Am I trying to get the data incorrectly?

 

Het IDE code

; PWM, 3 channels with different PWM frequencies, using MCMP
P1S   CNT    {  reg=A, irq=OFF, max= 2 }
P1E  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=0, action=PULSELO, reg=A, data=1, hr_data=64 };
P2S  CNT    {  reg=A, irq=OFF, max= 3 }
P2E  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=2, action=PULSELO, reg=A, data=2, hr_data=4 };  
P3S  CNT    {  reg=A, irq=OFF, max= 4 }
P3E  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=4, action=PULSELO, reg=A, data=1, hr_data=0 }; 
L00   PCNT { type=RISE2FALL, pin=6};
L01   PCNT { type=RISE2RISE, pin=7};
L02   PCNT { type=RISE2FALL,pin=8};
L03   PCNT { type=RISE2RISE,pin=9};
L04   PCNT { type=RISE2FALL,pin=10};
L05   PCNT { type=RISE2RISE,pin=11};
L06   BR { next=P1S,cond_addr=P1S,event=NOCOND};

Init code in my program

memcpy( (void *)&e_HETPROGRAM0_UN, HET_INIT0_PST, sizeof (HET_INIT0_PST));
	//Initialize high end timer
	hetREG1->PFR = 0x00000500; /* lr = 32; hr = 1 */
	hetREG1->DIR = 0x00000015; // 0,2,4 output
	hetREG1->HRSH = 0x00000037; //Set HR share for bits 6,8,10
	hetREG1->GCR = 0x00070001;

Trying to read the values

    uint32    pwmDuty   = (hetRAM1->Instruction[25U].Data) >> 7U;
    uint32    pwmPeriod = (hetRAM1->Instruction[26U].Data) >> 7U;

  • Hi David,

    In the HET IDE, the IO cell isn't modeled,  which is why you see separate busses for the het input and het output signals.

    Because of this you won't be able to see the signal that you drive out on one pin as an input to another pin.

    I think that with one of the Synapticad products you could create a test bench that looped back the in and out.

    In lieu of this what we do often is to just model the ins and outs separately in the IDE and then test on silicon.

  • Hi,

    Thanks for your response.  I should have been more clear.  I am not using the simulator, I am generating the code (.c/.h) and then loading it on to a board that has the lines jumpered together.

  • David,

    Sorry - my mistake.   It looks like you are using the 25U and 26U indices into the sample HET program that HalCoGen generates even with your custom program.  This might be the problem.

    Please take a look at the .h file that is generated by the HET IDE.  You should see
    lines that look like this:

    #define HET_START_0    (e_HETPROGRAM0_UN.Program0_ST.START_0)
    #define pHET_START_0      0

    #define HET_CAP_0    (e_HETPROGRAM0_UN.Program0_ST.CAP_0)
    #define pHET_CAP_0      1

    ...


    (This is from one of my own very simple HET programs where the first two lines were:

    START   CNT { angle_count=ON,reg=A,max=36000,data=0};
    CAP     PCNT { hr_lr=HIGH,type=FALL2RISE,pin=13};
    ...

    What's going on here?  The HET IDE is generating #defines for you so that you can symbolically point to the instruction index of your PCNT instruction by the name of the label you put in the HET assembly file.

    This is a lot better than hardcoding the value to 25U or 26U like the HalCoGen example shows, because if you make changes to your HET program the .h file just gets updated and if you only use the symbolic name in your C code your C code will track these changes.

    So for starters try replacing the 25U and 26U with the pointer to the relevant instruction - that should wind up helping a lot.

    For example, in my simple program I might have had something like:

    uint32    capVal  = (hetRAM1->Instruction[pHET_CAP_0].Data) >> 7U;

    You can also open a memory window on the HET memory and just visually confirm that these PCNT are working.  You should see the data field of the PCNT matching the values that you drive out on the PWM pins.  Then you can confirm that these PCNTs' are the ones that your C code is reading from.

  • Thanks for all of the info.  I've just started using the het ide and realizing its power and understanding how to use it.

     

    I am still seeing 0, but feel more confident in debugging now.

     

    Thanks

  • Thanks David,

    I just got an email w. a forum posting from you 'monitor if a signal has flatlined het ide' asking about how to use the DJZ.

    But clicking to reply the forum is returning a 'group not found' error.  Might be a quirk on our website right now.  Also this post isn't showing up in the listing under Hercules when I look...

    So answering here:  Try the BR instruction of the N2HET.  It has options to branch on rising / falling / both edges detected on a pin as well as pin is low or pin is high. (event=RISE | FALL | BOTH | LOW | HIGH )

  • Thanks.

     

    I just posted "generating interrupts het ide", maybe it is because I changed the name.

     

    I found the branch instruction and I think I have the logic sorted out, I am just unsure of how I know which of my three pulses will have tripped the interrupt, it looks like it is based on an offset, is this the program offset? Do I need to do anything special to enable the interrupts other than enable the high and low level het interrupts in halcogen?

    Also how I reset the counter value for the DJZ instr.

     

    I'll delete the post I just put up since we are responding here.

    Thanks

  • David,

    In general setting the IRQ=ON for the instruction is the first step.  Then you also have to enable the interrupt in the HET HETINTENAS register and potentially change it's priority.   You also have to do the normal things in VIM and in the CPU for interrupts.

    Please see section 20.2.7.   There is a table that explains how the HET instructions are mapped to 1 of 32 interrupt flags by their address.   So you need to pay attention to the location of these DJZ instructions as the LSB of their address will control which flag bit is set, and you can alias if you are not careful.  

    On the other hand - if you notice every single HET instruction has a NEXT= field so programs do not have to execute linearly at all.   You might want to take advantage of this and organize all your interrupting instructions together.  This way you can make sure they don't alias and that you don't go over the limit of 32 interrupts.

    To reset the value of your DJZ you can either write directly to it's data field using the CPU or you can do this from inside your HET program by using a MOV32/64 or one of the other instructions like ADC, that can update a remote data field.

    Doing this with the CPU can be useful if you want to make sure the HET falls into some known state if the CPU stops updating it.  You can do something like have a DJZ that will shut down your algo if the CPU stops feeding it tokens and implement a kind of watchdog function.

    Doing this with an N2HET instruction is a good way to update the DJZ synchronously with a HET loop resolution boundary and you can make use of logic on pins or counters to decide from inside the N2HET when it's time to reset the count.

    For your example, I would probably reset the DJZ every time the BR instruction detects an edge, and if it doesn't detect an edge I'd execute the DJZ.  When the DJZ counts down that's your signal that the pin has gone dead.

  • Great.

    Thank you so much for your help