[riot-notifications] [RIOT] [WIP] cpu/sam3x8e: Add pwm implementation (#3170)

A-Paul notifications at github.com
Mon Jun 8 17:39:52 CEST 2015


> +     *
> +     * The pwm provides 11 prescaled clocks with (MCK/2^prea | prea=[0,10])
> +     * and a divider (diva) with a denominator range [1,255] in line.
> +     * With every step the prescaler is doubled and the remaining quotient
> +     * is halfed and tested <=255.
> +     */
> +    if ( F_CPU < pwm_clk) { // Have to cut down resulting frequency.
> +        frequency = F_CPU/resolution;
> +    } else { // Estimate prescaler and divider.
> +        diva = F_CPU / pwm_clk;
> +        while ( ( prea < MCK_DIV_LB_MAX) && ( ~0xff & diva)) {
> +            prea = prea + 1;
> +            diva = diva >> 1;
> +        }
> +        frequency = F_CPU / ( ( resolution * diva) << prea);
> +    }

Please clarify what is considered as complicated.
The distiction for a case where the frequency should be cut in favour to provide the desired resolution is part of the interface description.
For the reason of estimating two scaler values please have a short look at the block diagram "38.6.1 PWM Clock Generator" in the [Reference Manual](http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf)

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3170/files#r31927685
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150608/d7f43138/attachment.html>


More information about the notifications mailing list