I'll apologize ahead of time for this long-winded post.
What I need to accomplish:
1. I need to PWM PB12 (PIN 25 according to the datasheet)
Hardware and software in use:
1. SAMD21J18A Xplained pro dev board
2. WINC1500 SSL example program (this runs and is working as desired)
What I understand:
Having read the datasheet and chased down as many dependencies as I could find, it seems I need to set the MUXEN bit associated with PORTB12 (physical pin 25 according to the datasheet) and map the pin to the peripheral function E as defined by the datasheet. I then need to set the period and duty-cycle and start the timer. Sounds simple enough, but I've run into some trouble understanding the hardware. The pin configuration registers start at address 0x40 and offset by the pin number. The pin I'm after is 25 making my target register address 0x59 (PINCFG25). Mapping the PIN to the required mux required me to identify if it is even or odd and add the value to the associated PMUX register. These registers start at address 0x30 + n*0x01
where n = 0:15.
Why I'm confused:
There are 64 port pins and only 32 configuration (PINCFG) registers. at the same time, there are 32 registers worth of PORTPINS for the PMUX registers but only 15 of them. I can't seem to figure out how to configure these registers given the possibility for duplicate resources. I've tried chasing this information down within the ASF PWM example, but it's written like a Russian nesting doll and I've been unable to locate the hardware layer abstraction (at least anything I would recognize).
What I'm asking for
A process I can use to setup PWM on PORTB12 (physical pin 25) and clarification on how the PINCFG and PMUX registers are supposed to be used. How do I identify the correct PINCFG and PMUX registers for the physical pin I want to use. Again, the MCU in use is the SAMD21J18A on the Xplained Pro board.
Thank you ahead of time for the help, Honestly, I had an easier time writing the MQTT client than I am trying to figure out this HAL.