Just a quick fix. I forgot to put the link in:

[1] https://github.com/RIOT-OS/RIOT/blob/master/boards/stm32f3discovery/include/periph_conf.h#L126-L147

On Thu, Feb 2, 2017 at 5:48 PM, Steffen Robertz <steffen.robe...@rwth-aachen.de> wrote:
Hi,

thanks for your response. Now i got all basic features to work. But I still have a Question:

In [1] pwm_config is initialized as a const. On the atmega256rfr2 i would need to save the calculated prescaler, so i can set it again on pwm_start() since there isn't a enable bit. The only way I know of is to disconnect the clock on pwm_stop() and then to enable it using the prescaler, calculated on pwm_init() again on pwm_start(). Therefore i would add another field to the struct and couldn't use it as a const anymore. Is this a valid approach or is there a different preferred way?

Thanks,

Steffen Robertz

On Mon, Jan 23, 2017 at 7:29 AM, Bas Stottelaar <basstottel...@gmail.com> wrote:
Hi Steffen,

Have you taken a look at existing implementations? For instance, the PWM driver for the STM32 [1, 2]?

* The pwm_init enables the PWM peripheral, given a frequency and resolution. Frequency and resolution relate [3]. * The number of available channels is returned by pwm_channels. Many MCUs have multiple channels (outputs) for one timer/counter.
* A value is set via pwm_set.
* The pwm_start/pwm_stop should start/stop the PWM, without disabling the peripheral. * The pwm_poweron/pwm_poweroff should power-on/power-off the peripheral.

You'll have to start by extending periph_cpu to add a definition for the PWM structure for your board (see [2] as an example). Then implement the driver (see [1] as an example).

Kind regards,

Bas Stottelaar

[1] https://github.com/RIOT-OS/RIOT/blob/master/cpu/stm32_common/periph/pwm.c [2] https://github.com/RIOT-OS/RIOT/blob/master/cpu/stm32_common/include/periph_cpu_common.h#L132-L150
[3] https://community.nxp.com/thread/97642

2017-01-22 18:03 GMT+01:00 Steffen Robertz <steffen.robe...@rwth-aachen.de>:
Hi,

I recently started using RIOT OS for my Bachelor Thesis.
My first task is to implement the pwm periphal in order to use it with an rgb led. And that already is where my problems start: I don't understand how the functions in pwm.h are supposed to work and therefore can't implement them in my pwm.c.

Can anybody provide more information than the comments in the pwm.h?

Any help will be appriciated.

Best regards,

Steffen

_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel


_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel

Reply via email to