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.

Varying PWM period on hercules

Other Parts Discussed in Thread: HALCOGEN

I'm trying to create a pulse train output from my TI Hercules tms570lc43x MCU. I can get a normal PWM out, but I want a pulse train that goes 10us on, 10us off,20 us on,10us off,40us on, 10us off ... I want to be able to double my on time for about ten rounds while keeping the down time the same. I was thinking of doing this by using an interrupt to turn my PWM output on and off from 100%, except i dont know how to do that. Can someone guide me into how to accomplish this?

Thanks

  • Dean,

    Is your resolution 10us? (do you ever say create a 10.2us wide on time?).

    Is there some equation that generates the sequence of on/off times?

    This seems like a task that you could easily program into N2HET...

    -Anthony
  • So here is a very simple program.

    It does something 'funny' in the PRST section mainly to set the pin low for the HET IDE you can strip this out for the final program but there is a quirk in the display on the HET IDE / Synapticad interface.   This PRST, PRST2 stuff just puts the pin in a nice low state on the display before the program starts.

    The HET IDE project has a memory trigger to 'turn on' the sequence at the 50us mark where it then generates 10us on, 10us off,  20us on, 10us off,  40us on,  10us off,  ...  by doubling the on time.

    Of course this can't double very many times before exceeding the 32-bit counter capability and the program doesn't try to saturate but this something you can easily add yourself if you like - here is just something to get you started.

    The program itself is:

    OUTPIN 	.equ 0
    
    CONST32          .macro CNAME,CVAL
    CNAME            .equ CVAL
    :CNAME:_LR       .equ CNAME / 128
    :CNAME:_HR       .equ CNAME % 128
                     .endm
    
    ; 10us is count of 1000 (3E8h) at 10ns clock
     CONST32 TEN_US, 3E8h  
    
    
    START    ADD    { src1=IMM,src2=ZERO,dest=NONE,data=0,hr_data=0};
    TSTART   BR     {event=NE, cond_addr = PULSCNT, next=PRST};
    PRST     MOV32  { remote=PULSMON,type=IMTOREG&REM,reg=NONE,data=TEN_US_LR,hr_data=TEN_US_HR};
    PRST2    DJZ    { next=PRSTH,cond_addr=PRSTL,reg=NONE,data=1};
    PRSTL    SHFT   { smode=OR0,cond_addr=START,cond=UNC,pin=0,data=0};
    PRSTH    SHFT   { smode=OR1,cond_addr=START,cond=UNC,pin=0,data=1FFFFFFh};
    PULSCNT  CNT    { reg=T,max=1FFFFFFh,data=1FFFFFFh};
    PULSCMP  ECMP   { en_pin_action=ON,cond_addr=PULSMON,pin=0,action=SET,reg=T,data=0,hr_data=0, next=START};
    PULSMON  DADM64 { next=PULSDBL,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMOFF,pin=0,comp_mode=ECMP,action=CLEAR,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};
    PULSDBL  ADD    {src1=REM, src2=ZERO, dest=NONE, rdest=REM, remote=PULSMON, data=0, hr_data=0, smode=lsl, scount=1, next=START};
    PULSMOFF DADM64 { next=START,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMON,pin=0,comp_mode=ECMP,action=SET,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};

    The simulation in HET IDE for the first couple pulses is:

    Project file is:

    8741.pulse_series.zip

  • Hi Anthony,

    Thanks for the response, I tried the code on HET IDE but for some reason I dont see the same signal. I am new to the TI MCU and don't really know what I'm doing in the HET IDE.  can you explain your code?

    Thanks

  • Also how would I modify the code to achieve a pulse train that looks like 10 10 20 10 30 10 40 10 50 10 65 10 80 10 100 10 130 10 150
  • Sure.  It's not much code at all.

    START, TSTART:      START is a dummy addition that discards it's result but sets flags to be tested in TSTART.

    Basically, this is the 'Enable' function for the pulse train.   If the immediate data field of START is zero, then TSTART

    sees the Z flag set and the condition 'NE' fails, so the code goes into the 'PRST' path which just resets the output pin.

    The data and hr_data fields of the START instruction are initialized to zero so this is the path that the program stays in until the external host writes a non-zero value to the data field of START.


    PRST, PRST2, PRSTL, PRSTH:   Ok really we don't need all this complexity.   A simple

    SHFT   { smode=OR0,cond_addr=START,cond=UNC,pin=0,data=0};

    Which drives the PIN 0 low is all that's needed for an output pin 'reset'.    But the HET IDE shows '0' as 'X' until the first time the pin changes to '1'..  then it shows '0' correctly.   This is some quirk of the 'value change dump' connection between the HET IDE and the Waveviewer.   So  I added some code to initially drive the pin '1' for one cycle (the DJZ counts 1->0) and then drive the pin low until the pulse train starts... just to make it visually easier to see where the pulse train starts in the HET IDE.    I'd simplify this out later..

    So the above is basically all related to 'reset' of this pulse train function.

    Now once the software driver on the host writes a nonzero value to address offset 0x08 into the HET RAM (data field of 'START' instruction),   the TSTART test will branch to the pulse train code at the start of every loop which is this:

    PULSCNT  CNT    { reg=T,max=1FFFFFFh,data=1FFFFFFh};
    PULSCMP  ECMP   { en_pin_action=ON,cond_addr=PULSMON,pin=0,action=SET,reg=T,data=0,hr_data=0, next=START};
    PULSMON  DADM64 { next=PULSDBL,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMOFF,pin=0,comp_mode=ECMP,action=CLEAR,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};
    PULSDBL  ADD    {src1=REM, src2=ZERO, dest=NONE, rdest=REM, remote=PULSMON, data=0, hr_data=0, smode=lsl, scount=1, next=START};
    PULSMOFF DADM64 { next=START,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMON,pin=0,comp_mode=ECMP,action=SET,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};
    The first line 'PULSCNT' is a counter instruction.   It simply increments the count value and makes a copy of it too into register "T" every time it executes.    Its initial data is set to 0x1FF FFFF so that the counter starts out with a value of '0' (0x1FF FFFF + 1 = 0 in 25-bits) . 

    The ECMP is what does all the work to turn the pin on and off.
    The ECMP starts out configured to drive the pin 0 high (action = SET)  at time 0.   Whenever ECMP's data field matches the counter value in register "T" it triggers the pin action and it also takes the 'cond_addr' path for the next instruction.
    On all the counts where it doesn't match it takes the 'next' path and just goes back to START where the HET waits until the beginning of the next loop resolution period.

    When the ECMP matches it takes cond_addr as mentioned above.   This points to either PULSMON or PULSMOFF. In fact it alternates between the two.    When PULSMON executes it changes the ECMP instruction to go to PULSMOFF on the next match.   And when PULSMOFF executes it changes ECMP to go to PULSEMON on the next match. 
    They also change the pin action from SET to CLEAR to SET to CLEAR... creating the toggle.

    This is the function of the DADM64 instruction which modifies both the data field and the control field of the ECMP instruction.   Now what i mentioned above is the 'Control' field stuff  (pin action, cond_addr...)

    The date field update changes the value of the compare register.    It simply adds something to the current count value to set the compare time for the next count value.  [the counter is not reset].

    The PULSMOFF instructon always simply adds 10us to the compare register since you wanted to always have a 10us off time.
     
    The PULSMON instructon starts off adding 10us,  but after it executes it goes to

    PULSDBL.    PULSDBL is an instruction that doubles the data field of PULSMON so that the next time it executes it adds 20us,  then the following time 40us,  then 80us, and so on.

    So that the high time gets longer for each pulse.   This is obviously not sustainable more than 20 or so times but it's just showing you a simple way to do some math.   You can change the math here to be more complex to fit your needs.   For example after doubling you could test against a max pulse width and pick the smaller of the two to implement a 'saturation' if you wanted that.   Options are really up to what you can code.



    So now hopefully that question about 10 10 20 10 30 10 40 10 50 10 65 10 80 10 100 10 130 10 150 is easier to answer.

    In this case you could add 10us 4 times,  then add 5us to the 10us to make it 15us.  Then add this 2 times,  then add 5us to make it 20us.   Then add this 2 more times.

    There could be a couple different ways to expand on PULSDBL to make it generate this pattern.  

     

    You should try to get the result repeated in the HET IDE though because in that environment you can single step through the HET code and really see everything that happens each cycle.  It's a very small loop so you'll understand it very quickly when you do this.


    Let me know what you are seeing in the HET IDE..  maybe paste some screen shots.

  • Thank You for the response I will try to change up the code a little, another problem I'm having is that I can seem to load the program onto the TI MCU. I have the HET IDE File, i basically assemble the code to generate the .h and .c files.

    I then go to Halcogen and turn on the het1 driver and then in the het1 tab I basically have the following setup:

    I then go to the pin0-8 tab and enable pin 2 (I'm using pin 2 on the board). I then generate code and then create a CCS project, and in the sys_main file type in hetInit() and while(1).

    However I keep getting an error as follows :

    Description Resource Path Location Type
    #10010 errors encountered during linking; "pulse_series.out" not built pulse_series C/C++ Problem
    gmake: *** [pulse_series.out] Error 1 pulse_series C/C++ Problem
    gmake: Target 'all' not remade because of errors. pulse_series C/C++ Problem
    symbol "HET_INIT0_PST" redefined: first defined in "./pulse_series/pulse_series.obj"; redefined in "./source/pulse_series.obj" symbol "HET_INIT0_PST" redefined: first defined in "./pulse_series/pulse_series.obj"; redefined in "./source/pulse_series.obj" pulse_series C/C++ Problem

    I dont know how to get rid of that to actually put the pulse train on my MCU and check with a scope.

  • So for the error, the issue is with the way HalCoGen makes a *copy* of your het code.

    It copies the .c and .h files you specify in the GUI into it's output folder /source/ whenever you 'generate'.

    Ok so that means you need to generate HalCoGen again every time you make a change in the HET program which gets tedious.

    But you're getting this error because both copies of the .c file are under the CCS build folder.

    A simple quick & dirty fix is to go to the ./source/pulse_series.c file (in HalCoGen folder), then right click on it and select 'exclude from build'.

    This will make the CCS build always use just the one copy of the .c file from your HET project folder, so now you just need to assemble changes in the HET IDE and then 'build' you program again to see the changes run on the EVM... but you don't need to regenerate HalCoGen files again if you do it that way.

    Note: There are better ways to use CCS's makefile include and pre/post build steps when you get deep into this but for what you're doing now I'd just go w. exclude from build...
  • I cant seem to figure out how to change the on times to my desired numbers. I can change the ten us to different values but the desired steps I want I cant seem to get, I also tried to make the pulse train stop after doubling 12 times by having a pulscmpr2 instruction but it seems to get skipped over everytime.

    Also in CCS im now getting a Error connecting to the target:
    (Error -600 @ 0x0)
    A required dynamic library could not be located.
    The library isn't on the search path.
    (Emulation package 6.0.407.3)

    Don't know what going on there.
  • Figured out the error now. But when I load into my MCU I dont see anything on the oscilliscope. It might be because the mcu cant physically keep on doubling the on time, due it being finite.
  • Dean,

    So if you want to make the doubling stop after 12 times you would do something like:

    PULSDBL DJZ { next=PULSDBL2, cond_addr=START, reg=NONE,data=12};
    PULSDBL2 ADD {src1=REM, src2=ZERO, dest=NONE, rdest=REM, remote=PULSMON, data=0, hr_data=0, smode=lsl, scount=1, next=START};

    For the other error that's looking like it's a CCS problem and you might post on the CCS forum.
    But it also looks like maybe you need to 'check for updates' and maybe restart CCS. The emulation driver package seems to be having a problem. If you did update recently and the update failed this could be the cause too... Anyway that problem isn't related to HET; it's completely separate.
  • Thanks A lot for your help Anthony, however I've loaded the code onto my MCU but I see nothing on the scope. I am expecting to see the 12 pulses and then a reset and then the 12 pulses again. The sequence should keep repeating, but right now I dont see a single pulse on my scope, my CSS code is as follows:

    #include "HL_sys_common.h"

    /* USER CODE BEGIN (1) */
    #include "HL_het.h"
    /* USER CODE END */

    /** @fn void main(void)
    * @brief Application main function
    * @note This function is empty by default.
    *
    * This function is called after startup.
    * The user can use this function to implement the application.
    */

    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    hetInit();
    while(1);
    /* USER CODE END */
    }

    Am I missing something?

    Thanks
  • Also I still cant figure out how to get the sequence I want for my output of 10 10 20 10 30 10 40 10 50 10 65 10 80 10 100 10 130 10 150. I'm not very familiar with the assembly syntax and logic.
  • Maybe.

    So i think in the code I sent you I put an equate for OUTPIN but I didn't actually use it in the code.
    I gave you lines like:

    PULSCMP ECMP { en_pin_action=ON,cond_addr=PULSMON,pin=0,action=SET,reg=T,data=0,hr_data=0, next=START};

    That you should change to:

    PULSCMP ECMP { en_pin_action=ON,cond_addr=PULSMON,pin=OUTPIN,action=SET,reg=T,data=0,hr_data=0, next=START};

    So that you can just change the Pin # in the .equ statement and be done ...

    There's a lot of these actually.. so search for pin= and get them all...

    Then you need to in HalCoGen make sure you have the pin you are using configured as an output
    (Direction bit must be set).

    And then you may need to do a pinmux check to make sure you have the HET controlling the pin you are monitoring.

    Finally you need to in your software write a non-zero value to the first address in your HET code.

    You can do this by:

    /* USER CODE BEGIN (1) */
    #include "HL_het.h"
    #include "pulse_series.h"
    /* USER CODE END */

    ....

    void main(void)
    {
    /* USER CODE BEGIN (3) */

    hetInit();
    e_HETPROGRAM0_UN.Program0_ST.ADD_INSTRUCTION_START_0.memory.data_word = 0x80;
    while(1);
    /* USER CODE END */
    }


    Now the compiler just thinks of e_HETPROGRAM0_UN as some external pointer to HET program, and you have to give it an address. One way is in the linker command file; add a statement at the end to point this to the HET RAM for HET0...

    /*----------------------------------------------------------------------------*/
    /* Misc */

    /* USER CODE BEGIN (8) */
    e_HETPROGRAM0_UN = 0xff460000;
    /* USER CODE END */
    /*----------------------------------------------------------------------------*/

    If you want to see an example of this there is a program to look at in www.ti.com/.../TIDM-HAHSCPTO

    there is a het program for example 'pto' and the host side driver that goes along w. the program gets installed in C:\ti\Hercules\HAHSCPTO\1.0.0\ccsproj\pto_common\source.

    This is code that is compiled to run on the ARM but it wiggles bits in the HET RAM to control key instructions and features of the function running on HET.

    You can think of these things as 'soft' hardware registers.

    For example if you think of the CNT instruction as hardware, envision it as a counter in a hardware timer.

    Then the ECMP instruction becomes a compare register for that counter...

    Now the ECMP register in our program is double-buffered but there are two buffers that it pulls from :
    PULSMON and PULSMOFF.

    If you wanted to re-initialize these to say 20us increments instead of 10us you could write a host side driver function that changed the data fields of PULSMON, PULSMOFF, and PULSCMP as well as PRST to some other value before releasing reset on the module. You'd use the syntax like above to write to the data field symbolically so you're not hard coding addresses that might change if you add a line of code to your HET program.
  • So for this you could use DJZ to count how many times you add.

    Psuedo-code could be something like:

    L1 DJZ {four times, jump to L2 on 'zero'}
    Add 10us and jump to START
    L2 DJZ {two times, jump to L3 on 'zero'}
    Add 15us and jump to START
    L3 DJZ {two more times, jump to 'start' on zero}
    Add 20us and jump to START

    This also saturates your count at the max value.. because after your third DJZ in L3 counts down you stop adding to the pulse width high.
  • hI Anthony so I added the code pieces into the sys_link.cmd file and the sys_main file but now I get an error saying: Description Resource Path Location Type
    #137 struct "<unnamed>" has no field "ADD_INSTRUCTION_START_0" HL_sys_main.c /pulse_series/source line 72 C/C++ Problem




    Also I tried to implement the pseudo code but it didnt work my code is as follows:
    OUTPIN .equ 2

    CONST32 .macro CNAME,CVAL
    CNAME .equ CVAL
    :CNAME:_LR .equ CNAME / 128
    :CNAME:_HR .equ CNAME % 128
    .endm

    ; 10us is count of 1000 (3E8h) at 10ns clock
    CONST32 TEN_US, 3E8h


    START ADD { src1=IMM,src2=ZERO,dest=NONE,data=0,hr_data=0};
    TSTART BR {event=NE, cond_addr = PULSCNT, next=PRST};
    PRST MOV32 { remote=PULSMON,type=IMTOREG&REM,reg=NONE,data=TEN_US_LR,hr_data=TEN_US_HR};
    PRST2 DJZ { next=PRSTH,cond_addr=PRSTL,reg=NONE,data=1};
    PRSTL SHFT { smode=OR0,cond_addr=START,cond=UNC,pin=OUTPIN,data=0};
    PRSTH SHFT { smode=OR1,cond_addr=START,cond=UNC,pin=OUTPIN,data=1FFFFFFh};
    PULSCNT CNT { reg=T,max=1FFFFFFh,data=1FFFFFFh};
    PULSCMP ECMP { next=START,en_pin_action=ON,cond_addr=PULSMON,pin=OUTPIN,action=SET,reg=T,data=0,hr_data=0};
    PULSMON DADM64 { next=PULSDBL,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMOFF,pin=OUTPIN,comp_mode=ECMP,action=CLEAR,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};
    PULSDBL DJZ { next=PULSDBL2,cond_addr=START,reg=NONE,data=12};
    PULSDBL2 DJZ { next=START,cond_addr=PULSDBL3,reg=NONE,data=4};
    PULSDBL3 DJZ { next=START,cond_addr=PULSDBL4,reg=NONE,data=2};
    PULSDBL4 DJZ { next=START,cond_addr=START,reg=NONE,data=2};
    PULSMOFF DADM64 { next=START,remote=PULSCMP,en_pin_action=ON,cond_addr=PULSMON,pin=OUTPIN,comp_mode=ECMP,action=SET,reg=T,data=TEN_US_LR,hr_data=TEN_US_HR};

    Basically for my project in order to get that camera to take pics at different exposures I have to get it to work on the 10 10 20 10 30 10 40 10 50 10 65 10 80 10 100 10 130 10 150 sequence. I basically want to have the MCU generate a pwm in that sequence of ons and offs and then repeat it forever.
  • Dean,

    Not sure about your unnamed struct problem but try starting again with the editor and typing in what I typed.  I didn't do it in the CCS editor.

    CCS has an auto-complete that will help you get it all right.  

    I fixed up the het code a bit..  

    Now it:

     1) sits idle till you write a '1' to data field of START.

     2) generates the series ending w. a 150us pulse

     3) after 150us pulse clears the '1' from START and resets all the counts

     4) sits idle again till you write a '1' to the data field of START.

     5) repeat #2.

     6) repeat #3...

    So you can trigger this sequence multiple times like in this screenshot where I triggered it 3 times:

    Seems to be like a 'flash' behavior where you trigger it once,  it does it's thing, and then you can retrigger again...

    Here is the .het file from the above photo: (not the whole project file so just copy/paste into your current .het file...

    2046.pulse2.zip

  • one minor point - the last pulse is 150.4us in synapticad and doesn't vary if I change the pulse width .equ. Not sure what that's really all about would want to look into it on silicon. but all the other pulses are dead-on your numbers.
  • Hi Anthony,

    Thanks for helping me with the HET IDE, I've loaded it into halcogen followed all the steps you listed. However I still get the construct error with the HETProgram0 command, and I'm still getting nothing on the output, I've configured the pin correctly on halcogen as well.

  • So I figured out the struct error, I was supposed to type in e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word=0x80; , I got rid of the ADD_INSTRUCTION part and the error went away.

    However there is no output from the mcu still.
  • What do you see in the HET register map?
  • this is what it shows:

    I tried running a regular pwm program from just halcogen to make sure there wasnt any problems with the board itself, and that program runs fine. I think I might need to fix something in HET IDE but im not sure what. Do you know what my specific settings should be for the TMS570LC43x board?

  • Sorry Dean, just to be clear, the picture you snapped looks good to me.
    The waveform shown for het.watch_2_out is the output we're trying to create.

    Just want to make sure you agree.. and that the problem is that you cannot get the same waveform from silicon.

    If that is a correct understanding, what i'd like to see is the HET register file from inside CCS when you program is running. We can examine the HETGCR and the HET GIO registers for example to see what's going on. Also you will see the HETADDR register update dynamically while your HET program is executing... These are signs the the HET is alive.

    If your program will run on a TI board you can also upload it.
  • Yes what I'm seeing in HET IDE waveviewer is exactly what I want to see coming out of the mcu board.

    This is the register map from CCS:

    as far as i can tell nothing is updating.

  • So the register map looks ok although I'd like to know if you see the ADDR register changing if you turn on the continuous (dynamic) update. This is like looking at the program counter and while it's 0 most of the time for a short HET program if you watch it for a while you should see other numbers appear there.

    The PFR register should probably be 700 instead of 600. this can be fixed by changing the loop resolution prescale to /128 instead of /64.

    You can leave it at /64 if you want but all the computed values for 'TEN_US' in what I gave you were based on /128. You'd need to double these values if you want to run at /64 instead of /128.

    You can run up to /128 without losing any resolution on placement of edges for your PWM output so it isn't really a problem to run at /128 with what we've talked about so far. So I'd 'fix' this unless you have something in mind that we haven't talked about.

    Then, can you poke a value into the DOUT register of the HET, a value of 0x0000 0004 .. and see this at least make a short spike high on the pin you are looking at? Depending on the HET program running it might set the pin back low clearing the DOUT register almost immediately after you write it, so just looking at DOUT in CCS isn't a good test. But if you check it w. the scope you are using an make sure you trigger on a rising edge then this would be a test the connection between HET and pin that you are probing is good.

    If you cannot see your changes to DOUT appear on the pin you are probing the obvious things next would be to check that your PINMUX is set correctly and of course that you are probing the correct pin.

    If you *do* see this connection between the DOUT register and the pin, then the next step is to check the HET program.

    Remember that we talked about HalCoGen making a copy of the program. If you decided to exclude the .h and .c files from the HET IDE folder from your build - you need to regenerate the HalCoGen code to re-copy them over into what's being built into the CCS program.

    You can also check the HET RAM after the memcopy in hetInit() to make sure that the program you *think* is copied into HET RAM is the one you expect.

    -Anthony
  • Does my LR Prescaler have to be 128 in Halcogen as well? adn what about HR Prescaler? I have my HR Prescaler in HET set to 1

    My settings in halcogen are:

    and I've only excluded the pulses.c file from the HET IDE in the CCS build. I left the .h file since it built with no issues. I went into view -> registers to see the HET registers, and even though I changed the LR prescale in HET IDE to 128 and then went to halcogen relaoded the .c and .h files and then hit F5, and finally rebuilt the ccs code the PFR value was still 600. Also I tried to poke a 4 at the end of Dout, it just reset to 0 right away, didnt see anything on the scope either

  • The ADDR register changes between 0 6 and 7, the ParADDR changes as well sometimes B4 sometimes A0 and sometimes 70
  • Well in HalCoGen I'd expect to see the LR prescale at 7 for /128 not 6.

    But if the base clock is 75MHz then anyway all the parameters in the program will need to scale as I calculated them using a 10ns HR clock not a 13.3333ns HR clock.

    I'm not sure what's going on in the GUI displaying 110MHz for the HR Clock but then using 75MHz for it in all the calculations. But that wouldn't really affect whether the program runs or not just the timing.

    If you cannot wiggle the pin then you should check the pinmux... You're looking on ball W5 correct? did you enable MibSPI4 or PWM3 instead of N2HET1[2] in pinmux for this ball?
  • yes I have the pinmux enabled for N2Het1[02] which is the w5 ball
  • I also just got an error saying that no source available for 0x0 in ccs
  • okay so now I just tried toggling DOut with the 4, and the scope just went high and its staying high. but the actual pulse sequence isnt being output for some reason
  • Dean,

    Great that's good progress.

    So this particular program is triggered in a one-shot fashion by writing to that first address in HET RAM.

    Maybe you should change the code so you can trigger multiple times to make it easier to catch on a scope.

    Does your scope store digitally / can it capture a one-shot?
  • How would I make it trigger multiple times? I figured having the while(1); in the main source would just repeat the HET file multiple times
  • What does your main function look like?
  • /* Include Files */

    #include "HL_sys_common.h"

    /* USER CODE BEGIN (1) */
    #include "HL_het.h"
    #include "pulses.h"
    /* USER CODE END */

    /** @fn void main(void)
    * @brief Application main function
    * @note This function is empty by default.
    *
    * This function is called after startup.
    * The user can use this function to implement the application.
    */

    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    hetInit();
    e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word=0x80;
    while(1);
    /* USER CODE END */
    }

    /* USER CODE BEGIN (4) */
    /* USER CODE END */

    Here you go
  • So try this:


    void main(void)
    {
    /* USER CODE BEGIN (3) */
    hetInit();
    while(1)
    {
    while (0 != e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word);
    e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word=0x80;
    }
    /* USER CODE END */
    }
  • btw i had to turn master clock mode off in halcogen to get the Dout to trigger something
  • That makes sense to some extent because the program we loaded into HET sits in a tight loop writing 0 to the pin during 'reset' [data field of first instruction = 0]
    Changing it to a clock slave basically keeps the program from running.
    You need to change it back for the program to run.
  • okay so i turned master clock mode on again, but still the pulse train wont show up on my scope
  • I also went into HL_het.c, and went to void memcpy in hetInit() but I'm not sure how to verify if the correct het file was loaded there or not heres what it looks like:

    (void)memcpy((void*)hetRAM1, (void*)HET_INIT0_PST, sizeof(HET_INIT0_PST));

    /** - Setup interrupt priority level */
    hetREG1->PRY = 0xFFFFFFFF;

    /** - Enable interrupts */
    hetREG1->INTENAC = 0xFFFFFFFFU;
    hetREG1->INTENAS = (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U
    | (uint32) 0x00000000U;


    /** - Setup control register
    * - Enable output buffers
    * - Ignore software breakpoints
    * - Master or Slave Clock Mode
    * - Enable HET
    */
    hetREG1->GCR = ( 0x00000001U
    | (uint32)((uint32)0U << 24U)
    | (uint32)((uint32)1U << 16U)
    | (0x00020000U));


    /* USER CODE BEGIN (4) */
    /* USER CODE END */

    }

    /** @fn void pwmStart( hetRAMBASE_t * hetRAM, uint32 pwm)
    * @brief Start pwm signal
    * @param[in] hetRAM Pointer to HET RAM:
    * - hetRAM1: HET1 RAM pointer
    * - hetRAM2: HET2 RAM pointer
    * @param[in] pwm Pwm signal:
    * - pwm0: Pwm 0
    * - pwm1: Pwm 1
    * - pwm2: Pwm 2
    * - pwm3: Pwm 3
    * - pwm4: Pwm 4
    * - pwm5: Pwm 5
    * - pwm6: Pwm 6
    * - pwm7: Pwm 7
    *
    * Start the given pwm signal
    */
    /* SourceId : HET_SourceId_002 */
    /* DesignId : HET_DesignId_002 */
    /* Requirements : HL_SR364 */