Search found 4 matches

by flagman
Fri Mar 28, 2014 10:32 am
Forum: STM32 Support
Topic: sinus emulation with pwm on stm43f4-discovery howto?
Replies: 7
Views: 5785

Re: sinus emulation with pwm on stm43f4-discovery howto?

You are calling a pwmEnableChannel() from a callback, you cannot call normal APIs from ISR context, only I-Class functions.
Giovanni

like this?
#include "ch.h"
#include "hal.h"
#include "math.h"

static WORKING_AREA(pwm_ThreadWorkingArea, 128);

extern double angle;
extern double pwm ...
by flagman
Thu Mar 27, 2014 10:09 am
Forum: STM32 Support
Topic: sinus emulation with pwm on stm43f4-discovery howto?
Replies: 7
Views: 5785

Re: sinus emulation with pwm on stm43f4-discovery howto?


Probably main thread hangs... at compile time i`ve got warning:
..\main.c(17): warning: #1035-D: single-precision operand implicitly converted to double-precision
angle += 0.5;
may be this causes this behavior of the board.
I`ve changed increment to 1, warning disappears, but no changes on ...
by flagman
Wed Mar 26, 2014 11:18 pm
Forum: STM32 Support
Topic: sinus emulation with pwm on stm43f4-discovery howto?
Replies: 7
Views: 5785

Re: sinus emulation with pwm on stm43f4-discovery howto?

You may generate the sinus directly via DAC.
This is good point. Can you provide some example code for this?

I have tried to use timers callback function to change pwm duty cycle. It works, generally, but some thing wrong with main loop.

#include "ch.h"
#include "hal.h"
#include "math ...
by flagman
Wed Mar 26, 2014 6:22 pm
Forum: STM32 Support
Topic: sinus emulation with pwm on stm43f4-discovery howto?
Replies: 7
Views: 5785

sinus emulation with pwm on stm43f4-discovery howto?

Hello all!
I`m trying to make emulation of sinus signal with pwm on stm32f4-discovery board.
Here is my code:

#include "ch.h"
#include "hal.h"
#include math.h

static PWMConfig pwmcfg = {
10000000, /* 10Mhz PWM clock frequency */
220, /* PWM period 220 duty cycles */
NULL,
{
{PWM ...