-->
Page 10 of 10

Re: Announcement: Replacement PWM implementation available

PostPosted: Sat Sep 17, 2016 7:06 pm
by StefanB
eriksl wrote:The key is choosing the "right" values for period and duty, they're different than you're used to, they both count in 200 nsec (5 MHz source clock) slices now. So suppose you want a 16 bit / 76 Hz timer, you specify 65536 as the "period" and then the duty can be 0 - 65535. Similarly, for a 15 bit / 162 Hz timer, you specifiy 32768 as the period and the duty can ben 0 - 32767. And #undef compatibility mode.


For 100% duty, you should specify the same value as for period, not 1 less - period is the maximum value, not the number of steps.

Re: Announcement: Replacement PWM implementation available

PostPosted: Sat Sep 17, 2016 8:49 pm
by StefanB
eriksl wrote:
Code: Select all+__attribute__((pure)) uint32_t ICACHE_FLASH_ATTR

+__attribute__((const)) uint32_t ICACHE_FLASH_ATTR


the "pure" and "const" attributes are only useful for function declarations, not function definitions. These are hints for the compiler which optimizations it can apply, i.e. if it is save to replace two calls to a function with a single call and reuse the return value.

Please see the GCC documentation for details:
__attribute__ ((pure))
__attribute__ ((const))