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.

RM48L952 Single Wire Communication, 400 nanosecond resolution

Other Parts Discussed in Thread: HALCOGEN

Hello,

I am trying to communicate with part WS2812B (spec attached) over a single wire.  Per spec, it requires the signal to be held high for 400 nanoseconds +- 150 nanoseconds.  Is this feasible using Terminal A9, NHET1[27] pin?

Currently, I am able to get 1900 nansecond resolution, but not much smaller.

3782.WS2812B.pdf

Thanks.

Ubaid

  • Attaching HET1 Timing Configuration for reference. As well as some sample code on how we evaluate how much time has elapsed:

    void   BSP_OS_TimeDlyNs (CPU_INT32U  dlyNs)
    {
    	_pmuResetCounters_();
    	_pmuStartCounters_(pmuCOUNTER0);
    
        while (_pmuGetCycleCount_() < dlyNs) ; 
    
    }
    

    Ubaid

  • Ubaid,

    If you are using the stock HET program the comes with HalCoGen then you shouldn't be able to get a pulse out at 400ns because the PWMs used by this program run at loop resolution.

    You'd need to reduce the program size and drop your prescale from 7 to 4 or 5 (limiting you to 31 instruction execution cycles, and probably a few less actual instructions if you have some that are not single cycle).

    Or you can use the Hi-Res feature.

    Which to use?

    The pulse width of 400ns doesn't give the complete answer. What is the shortest 'period' you need to produce. Even if the signal isn't periodic -- what's the shortest time from rising to rising edge or falling to falling edge that you need to produce?

    Also, with this shortest period - do you need to produce multiple of them back to back, or just 1 occasionally.

    The answers to these questions will help determine the approach to use.

    Thanks and Best Regards,
    Anthony
  • Thanks Anthony,

    Did you mean, I should or shouldn't be able to meet the 400ns requirements?

    Rising to Rising edge is 1.25 microseconds with an intermittent delay of 50 microseconds (as RESET signal) Also, yes this will be back to back.

    Thanks.
    Ubaid
  • Handling RESET signal is most probably not a concern. It is the rest of the communication that would be time critical.

    A bit value of 1 is interpreted as: 800 nanoseconds high, and 450 nanoseconds low
    A bit value of 0 is interpreted as: 400 nanoseconds high, and 850 nanoseconds low

    Data is sent up to 9 bytes at a time.

    Ubaid
  • Ubaid,

    This example het IDE project might get you started.

    Run for some cycles like 50 loops then enable the program by writing a '1' to the data field of the 1st instruction.

    (you can just 'poke' this value into memory in the IDE) ..  

    That enables the shifting.   Shift register is 'SHBIT' and it's loaded with 0xAA to start.  Shifts LSB first, you can change this though if you want by adjusting the shift type, direction, count..    Just study the syntax of the ADD instruction and it's shift options.

    I had to set the prescale to 5 to make this work - which leaves 32 cycles for theHET program.

    There might be some trickery to stretch to 64 cycles but this program is pretty short, 10 cycles to execute during the longest loop so you could add more functionality before you hit a limit.


    Some comments to read once you get into the code and understand it:

       a) The Macro 'CONST' doesn't work (syntax error) if you pass a value that's a float to it.
           This I think is a limitation of the assembler or at least a limitation on my ability with it.

           Since I set the HET clock to 100MHz or 10ns,  800/10 comes out as an integer and the macro works ok.

           If you set to 9.9ns for 110MHz then you'll need to do the computation outside the assembler and put an integer as the 2nd parameter of the macro.   I just wanted you to understand what's going on here:

         CONST    TIME_ONE_H,  ((800/HR_CLK_PER)*4)    

    So I left as a formula.   I couldn't figure out a way to get the power or exp function in the assembler, so the '4' is hard coded and related to the LRP prescaler of '5'.   It would be  2^(7-LPRES)  in the forumula - where ^ is 'power' not XOR.

    I didn't bother testing this but you should be albe to try writing new data to SHBIT and then writing length-7 to NXTBIT (data fields) when the transmission finishes to start off a new transmission. 

    Anyway this is only meant to get you started.

    Picture of 0xAA transmitting below.   In Synapticad, you can measure the time by left clicking on 1 edge then moving the cursor to another edge.   The upper right window shows the absolute time in black and the delta time in blue - so the delta time is the edge-to-edge time. You can measure at 800ns, 450ns, etc...  of course in the screen capture I took I botched this and the delta shows -6.8 us!

    -Anthony4064.starter_microwire.zip

  • Can you please detail how a high resolution timer can be enabled?  What Halcogen settings and/or registers need to be modified to enable this feature?

    Thanks.

    Ubaid

  • Hi Ubaid,

    In HalCoGen, you would select the custom program with the box below

    Also use HalCoGen to set the pin direction - you have an output pin so you need to make sure it's port is setup as an output.
    I used pin '0' but you can easily change this in the assembly .equ statement.  EDIT:  And use HalCoGen to set the LR prescaler
    value to 5 (/32) as well.

    In your program, you need to include the header file simp_pwm.h in addition to het.h. You can use the structures defined in this header to write to specific addresses in the custom program.

    You only need to write to 3 locations -

    pHET_START_0  - write '1' to the data field to enable.

    pHET_SHBIT_0  - this is your 'transmit buffer' of sorts

    pHET_NXTBIT_0 - this would be your bit count - 1. write value of  7 for 8 bits ..

    After you include simp_pwm.h you should be able to create pointers to the particular instructions like this:

    hetINSTRUCTION_t *pSTART = &(hetRAM1->Instruction[pHET_START_0]);

    (make sure to pick the correct hetRAM - has to match the HET that you load the program into and you have 2 HETs..)

    pSTART->Data = 0U; 

    to write to the 32-bit data field of the start instruction.

    But please look at the program in the HET IDE first, and make sure you know how it is works so you'll understand it when you get to silicon.  It's harder to debug HET issues on silicon than the simulator. 

    -Anthony

  • Thanks Anthony,

    Please ignore my last message. If we use the HET IDE, does that mean we need to reprogram all existing PWM functionality that we have configured via HaloGen and Code Composer?

    Thanks.
    Ubaid
  • Ubaid,

    I don't know. There are 2 HETs on your part. So you could leave 1 running the default HalCoGen config and the 2nd running this code plus code to generate extra PWMs. Or if you already are using 2 HETs then yes you need to move the functions you are using on one of the HETs into this code. However, I think you'll find that it's not that difficult to do, especially with this starter code.

    -Anthony
  • Thank you Anthony,

    This is good information and will need some time to review.

    Is the HET IDE a TI tool? I notice that we need a license to use it. Also, are there any additional resources for using the HET IDE?

    Thanks.
    Ubaid
  • Ubaid,

    It's licensed yes, but the price is free and you can download it http://www.ti.com/tool/het_ide.

    It installs a few tutorials and demos into: <user dir>\Documents\Texas Instruments\Hercules\HET
    (not the same folder as the executable). You can run through those.

    The file I uploaded is a complete HET IDE project folder though - kind of like a CCS project.
    You should be able to open it in the HET IDE (Project->Open Project).
    However - it would be a good idea to open the .prj file in a text editor and edit the paths.
    Unfortunately the project file is written out with absolute paths to the source file, and project directory, so the path names in the .prj file are from my PC :( But it's just an XML file and you shouldn't have trouble finding the paths and replacing them with the path where you unzip.

    Once you do that - should be able to just run the project and get the same results I sent a screen shot of.

    Do remember though to write the value of 0x1 in the IDE memory window to the data field of the "START" instruction to turn on the program. It defaults to an idle state where it does nothing until enabled - which is useful for when you run on real silicon.

    You should just need to run about 50 loops after you enable the program and that'll be enough time to get the 8 bit word transmitted. You may have to learn to zoom in and out in Synapticad to find the data word though. There is an icon in the HET IDE with a run symbol and a box with a count in it. If you put 50 in the box, and use the run symbol to it's left - the simulator will run 50 loops then stop. Otherwise there is also a single-step button if you want to execute one instruction at a time and view the results. That's handy because you can see register values and flags that are not visible on silicon.

    A tip to zooming is that you can use the magnifier w. F by it to get the full picture.
    Then you click on the area in the waveform that you want to zoom into, and after that use the magnifier to zoom in. The 'click' you did before zooming sets the center point of what you see when you zoom in. If you don't click first then you'll have to scroll around and I find that a bit tedious when the waveform is a short burst in a long trace.


    Best Regards,
    Anthony
  • I was able to achieve the timing requirements without using pmu timers. I re-issue the same instruction numerous times. Probably should just move the logic to assembly.
  • Ubaid,So you're using the CPU instead of the N2HET ?
  • Hello,

    I was hoping to use the pmu timers, but i couldn't get the time granularity down enough to meet the requirements. For this reason, I am am using the CPU.

    Ubaid
  • Hi Ubaid,

    Hmmm.     So PMU = Performance Monitor which is part of the CPU.     Is that what you had tried. ?

    DId you ever give the N2HET program a look.   I think this is the best way to go personally.

  • I initially tried the performance monitor unit driver.

    I did not, mainly because we did not want to risk the functionality we have already completed. We did reassign some pins so that we can free up some pins for the NHET2 block to be used as pwm. We were under-utilizing NHET2 block for pwms.

    Ubaid