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.

Timer Synchronisation in TMS320F2812 EV modules

Other Parts Discussed in Thread: TMS320F2812

Hello 
I am using TMS320F2812 in my project. I want to generate 6 independent PWM pulses using both EVA and EVB. How can I synchronize timer1 of EVA and timer3
of EVB? I saw this thread as an answer.
e2e.ti.com/.../132960
But I'm programming in C. How can I put the timers in stop mode and start them simultaneously?

Thank you


  • Hello,

    You could use the "__asm()" keyword to specify inline assembly in your C program. That way you can use the technique mentioned in the thread you linked to without having to worry about the compiler optimizing the code and messing up the timing.

    Whitney
  • Hi
    Thanks Whitney. I'm new to this and not well verse in assembly language programming. There was no program in that thread I referred to earlier. How can I do it in C itself?
  • It's still the same steps but in regular C code using the regular C header files that our examples use.

    1. Stop both timers.

    2. Set T3CNT and T1CNT so that T3CNT is a little bigger.

    3. Start T1.

    4. Start T3.

    5. Experiment with how much bigger T3CNT needs to be to get them in sync.

    To make it less likely for the compiler to optimize this sequence and change the timing, you could put this code in a function and put it in its own file since you can set optimization levels by file.

    The safest choice is still to learn some assembly. There's a document for it here, and pulling up the disassembly window in CCS while you're debugging and stepping through the code can be a good way to learn too.

    Whitney

  • Hi Whitney,
    Thanks for your reply. I've been trying the same for a few days. First I tried to use logic and now I'm using brute force. How much difference will there be between T1CNT and T3CNT? I'm currently at 3F. I just need a range. And there is one more doubt. I'm using up/down counting mode of timers. So the difference between the counters at any instant of time should be a constant as per my understanding. But it varies. What could be the reason?
    Regards
    Murali
  • Murali,

    You can look at the distance between the two output signals on an oscilloscope and calculate how many clock cycles they are apart. You could also try looking at the disassembly, counting how many instructions there are between T1 starting and T3 starting, and deriving the necessary difference from that.

    This sort of synchronization has been made much easier in our PWMs on our newer devices, so I unfortunately haven't been able to find any examples that demonstrate this strategy.

    Whitney
  • Whitney,
    I am using the watch register option in CC studio. I increase the counter,then debug,stop and look at the two counter registers. Is it a wrong method? It's for a college project and the only available DSP is TMS320F2812. So changing the processor is not an option for me.
    This is what the timer start looks like. I have put the two timers in stop mode in the initialization function and start them in the main function. And my high speed clock pre scalar division is 1.

    0x3F8AB1: 761F01D0 MOVW DP, #0x1d0
    0x3F8AB3: 1A040040 OR @0x4, #0x0040
    0x3F8AB5: 761F01D4 MOVW DP, #0x1d4
    0x3F8AB7: 1A040040 OR @0x4, #0x0040
    I think it should be a small difference between T1CNT and T2CNT but i can't seem to sync them so far.
    Thank you
    Murali
  • I don't know what clock source to the EV you're using, but I agree that it looks like it should be a very small difference.

    Can you look at the PWM signals on an oscilloscope? That is a more accurate way to observe how in sync the signals are. I don't know the details of the debug behavior of this device, but if the timers are still running, it is likely you will see a difference in the register window because they aren't actually being read at the exact same time.

    Whitney