I have a newby question about PWM on SITCore devices. Reading through the tutorial, I noticed there is a separation between PwmController and PwmChannel. I read the notice saying not to use GetDefault() method like other peripherals, but I still don’t understand the difference between the two objects.
If I wanted to fade two separate LEDs independently, could I use the same channel? Could I use the same controller? From a physical standpoint, what does each control? Please assume I know nothing, thanks!
A controller may have just one or more than one channel. If channels have same controller will have same frequency but can set to different dutycyle.
you should use two channels.
GetDefault() is used for some peripheral has only one controller (gpio, usb host, usbclient, watchdog…). Some peripherals has more than one controller (pwm, spi, i2c…) you need to point out what controller you wanted to use.
Alright I think I understand, to reiterate so I understand:
- A single pwm controller operates at one frequency but can host multiple pwm channels.
- A pwm channel is one subset of a pwm controller, usually connected to one external device, and can have its own duty cycle.
- To control two separately fading LEDs, I could use either one or two controllers, so long as they have different channels with their own duty cycle.
If I misunderstood, please let me know–otherwise, I appreciate the clarification!