Need advice on how to set up PWM using AtmelStart

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I'm looking for guidance on how to approach what I hope is a simple problem. I'm trying to use AtmelStart to setup a program for a SamC21NXplainedPRO board to drive the D6 pin (TC0/WO[0]).

The problem appears to be that the PWM is being generated to run in Match Pule-Width Modulation Operation (MPWM), which is only able to use the TCO/WO[1] pin for waveform generation, and the TCO/WO[0] pin to create a negative pulse. I'd like to switch the operation mode to Normal Pulse-Width Modulation Operation (NPWM), which I believe allows both of the WO options to be used for waveform generation. I do not see any settings in AtmelStart which seem to allow me to change the operation mode of the PWM. I believe I am able to change the operation using the WAVE.WAVEGEN register, though I don't think it would be as simple as just changing the operation mode and expecting everything else to perform the same, and I'm trying to minimize complexity in this project, if possible. 

Thanks in advance

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you need to use the Lite:TC:PWM driver. 

/Lars

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lars,

Thank you! That absolutely is what I needed to do, and now I've gotten the appropriate pin outputting PWM's. My only confusion now is, how can I control the duty cycle of the PWM beyond the initialization? I understand that I need to change the CCx registers, but I'm not sure how I can do that without using the HAL functions such as pwm_set_parameters(). 

Thanks again,
John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can write directly in the registers. Or use the hri functions like hri_tccount8_write_CC_reg.

/Lars