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.

Can TM4C123 PWM get updated from uDMA?



In the datasheet, it appears that the uDMA module does not have a channel that can be triggered by a PWM.

Is it still possible to setup a DMA channel to be triggered by a GP timer but transfer data from memory to the PWM compare registers?

 

Thanks

  • Hello Maxpower,

    Yes it is possible to set a Timer to generate DMA to transfer data from memory to PWM compare register. However the two events, i.e. Timer Interrupt periodicity and the PWM period of operation must match exactly.

    Regards
    Amit
  • Amit,

       Thank you for your response.

    Does this mean the PWM compare register can't be written to asynchronously?

    I am new to this microprocessor but I am very familiar with the C2000 series. In the C2000 you can write to it asynchronously. Depending on the application, writing asynchronously may or may not be an issue but it can easily be done in the microprocessor.

    Thanks

  • Hello Maxpower,

    The register PWMCTL (offset 0x000) can be used to synchronously load values. The register PWMxCTL at offsets (0x40, 0x80, 0xC0 and 0x100) control generator specific update mechanism synchronously.

    Query: May I ask why move from C2000 to TM4C?

    Regards
    Amit
  • Amit, thank you again for your quick responses!

    Since these registers are synchronous. Does that mean they need to be updated coincident with some event? Which event?

    In my current case, I can run the timer at the same frequency as the PWM however, I don't understand how they are synchronized. What I want to do is to generate a pwm signal based on RAM values that are sent to the PWM on each PWM cycle by DMA. I need this to happen without any processor overhead. I can do this on C2000.

    The reason why I am not using a C2000 is that this is a new and different application that requires more communication interfaces. The TIVA C development boards that we got seem like a good fit, however, I need to generate a high speed signal from the PWMs.

     

    Thanks

  • Hello MaxPower,

    The register can be written at any time. However the PWM module will load it internally on the event mentioned in the register bit setting. As an example if the setting is for synchronous update on zero count, the value in the Compare register will be loaded into the generator when the internal counter reaches 0.

    The PWM and Timer are not synchronized but only maintaining a timer period relation. Alternatively, the PWM IO toggle (rising or falling edge) can be used to generate a DMA request from the corresponding GPIO Port. This will be always synchronous unless the DC becomes 100% or 0%.

    Regards
    Amit
  • Amit,
    The way you are decribing the way the PWM works, w.r.t. loading the new compare value, is the same as the C2000. Now I understand what you mean by synchronous.
    I like your idea of using a GPIO pin to trigger DMA that is coming from the PWM itself. I think that will give me what I want. Now I just need to see if one of those GPIOs are available (I.E. not being used as another function).
    Thanks!
  • Hello Maxpower

    The GPIO for PWM output can still be used to generate an interrupt even though it has been configured for PWM function.

    Regards
    Amit
  • Amit,
    I understand that part. I meant the GPIO input that triggers a DMA transfer to the PWM. I don't know if those GPIOs are currently assigned to other function. I just need to talk to hardware folks to find out.
    Thanks
  • Hello Maxpower,

    OK, let me clarify: The GPIO Pin which is working as a PWM output can be configured to generate an interrupt/DMA on edge detection. This way you do not need to use another GPIO to generate the DMA request.

    Regards
    Amit
  • Amit, Wow. That looks like it will work. I will give it a try.
    Thanks for all the help!
  • Hello Maxpower,

    There is a thread on the forum in last 2-3 weeks where a forum member wanted to do exactly the same. I am not sure if there was a simplified code on that post or not.

    Regards
    Amit
  • I am finally at the point where  can work on this. I have PWMs working. I also have uDMA working with a software trigger in BASIC MODE. I also believe I have the PWM triggering the DMA transfer once in BASIC MODE. What I need is for the PWM to continually trigger the DMA to sequence through a table of data and reset to the beginning of the table, all without software intervention. Again, the 28335 can do this.

    I am experimenting with PING PONG Mode but that is not working yet. Right now, I am just trying to transfer one memory location to another but triggered from the PWM. It seems to trigger once but never again.

    Once I can get it to continually trigger, I will try to get it to transfer data from a table, one entry per PWM trigger but then reset at the end of the table. Now that I am understanding this processor's DMA, I don't think it can do this?

    The PWM trigger is happening at a very high frequency and can't have software intervention.

  • It looks like I need to use the scatter/gather mode. Set the number of tasks to the number of items in my table so it iterates one by one. At the end of the task list, an interrupt is generated. While this is not ideal for me, it may be tolerable. I am still not following the interrupt part of this. The uDMA interrupt only occurs after a transfer initiated by software. In this case, it is being initiated by a GPIO pin that is also being used by a PWM.

    The documentation says that in scatter/gather mode, the interrupt at the end of transfer actually come from the peripheral which in my case is a GPIO pin. How do I configure the GPIO pin to be an interrupt at end of transfer for the DMA channel associated with it without it actually generating an interrupt on every edge?
    Thanks
  • Hello Maxpower

    What is the PWM triggering rate. Note that in Ping Pong or any other mechanism, the control structure needs to be reinitialized when DMA DONE is asserted

    Regards
    Amit
  • The rate is in the 100s of kilohertz.

    I have configured the PWM output GPIO pin as the DMA trigger. I also configured that GPIO pin as an interrupts. I configured the DMA channel as a scatter/gather with the number of tasks being equal to the size of my table. The DMA gets triggered once but does not re-trigger. As you said, I will need an interrupt to do that. While that is not ideal, and different from the 28335, I think I can work with that. Unfortunately, I can't get the interrupt to fire.

    I am using TI RTOS but not using those APIs to configure DMA or PWM. I have enabled the interrupt using the MAP_ function as well as telling the TI rtos to route interrupt 16 (GPIO A pin 6) .

    I hope I get a breakthrough soon.

    Thanks
  • Hello Maxpower,

    I think I saw such an issue on the forum and the problem turned out to be the fact that the trigger was not being generated from the peripheral but the channel was enabled.

    Regards
    Amit
  • I found it!!!

    I missed an important part in the documentation that says the interrupt does not get generated unless the last task has its mode set to UDMA_MODE_AUTO. I did that and I am now getting interrupts.

    I must have read this many times and i just didn't see that. Additionally, you can have the last task, copy the initial structure state so that it loops on itself.

    Thanks again for all the help!