PWM (Pulse-width modulation) is a technique for controlling power to electrical devices, made practical by modern electronic power switches.
Questions tagged [pwm]
468 questions
2
votes
2 answers
PWM DMA to a whole GPIO
I've got an STM32F4, and I want to PWM a GPIO port that's been OR'd with a mask..
So, maybe we want to PWM 0b00100010 for awhile at 200khz, but then, 10khz later, we now want to PWM 0b00010001...then, 10kHz later, we want to PWM some other mask on…

testname123
- 1,061
- 3
- 20
- 43
2
votes
1 answer
STM32F746ZG TIM8 PWM Not working
I can't seem to get TIM8 PWM to work with anything that I try. I've tried all timers and they all work with my PWM driver, except TIM8. All timers are generated with CubeMx and there are no conflicts.
Here are some snipits of the code. The driver is…

user2654735
- 323
- 5
- 19
2
votes
1 answer
How to use pwm.h
How can I use ESP8266 library pwm.h? If I just include the library in my arduino project, I get an error: undefined reference to pwm_init
I need a 40khz sine wave for ultrasonic sensor and analogWrite works bad at high frequencies.
Sorry, if the…
user5431481
2
votes
1 answer
PWM frequency and duty cycle on raspberry pi for ESC
I'm using a Raspberry Pi 3 to try and control a brushless DC motor via a QBrain ESC.
To do this I use the RPI lightning drivers to create PWM DMA signals. Unfortunately nothing I do will get the motors turning.
Can someone advise what frequency and…

Slicc
- 3,217
- 7
- 35
- 70
2
votes
1 answer
Move PWM from pin 3 to 11 (Arduino Nano)
I am trying to modify this code to move PWM from pin 3 to 11 (Arduino Nano v3), but have not had much success. How can it be done?
pinMode(3, OUTPUT); // enable the PWM output
TCCR2A = B00100011; // Fast PWM change at OCR2
TCCR2B =…

bbglazer
- 123
- 3
- 16
2
votes
2 answers
Generating a variable frequency PWM signal for AVR
I want to generate a PWM signal with variable frequency and a fixed duty cycle(50%). Frequency should vary between 0-25KHz. This is for a ATMEGA32U4 microcontroller and I'm writing it in C using Atmel Studio. I did read the datasheet but I can't get…

ADGAN
- 31
- 1
- 7
2
votes
2 answers
Raspberry Pi PWM accuracy, Python
I have a simple Python program running on a Pi 2. I can't seem to figure out why the output frequency is way off. I have it programmed for 2000hz. I measure the output two ways and both yield 1530 Hz.
Since I use pin 18, I believe I should be…

Rob
- 41
- 3
2
votes
1 answer
In Raspberry Pi 2, how to configure PWM1 channel?
I could drive a servo by using PWM0 channel on GPIO 18 of Raspberry Pi with following c code:
#define BCM2708_PERI_BASE 0x3F000000
#define PWM_BASE (BCM2708_PERI_BASE + 0x20C000)
#define CLOCK_BASE …

mohasalah
- 43
- 2
2
votes
2 answers
dsPIC33EV256GM002 PWM settings
I developed a simple program to produce PWM waveform on dsPIC33EV256GM002 but I can't disable it. I used PWM1 and PWM2 and I would generate PWM waveform on PWM1L1 pin (pin 26 on DIP package) maintain PWM1H1 (pin 25 on DIP package) as digital…

Ferrari
- 75
- 1
- 11
2
votes
1 answer
LabVIEW case structure and PWM
I am facing a trouble with LabVIEW; I am working on this simple program which is a part of a bigger school project. For some reason, a part of it isn't being executed properly. Simply put, a green LED should turn on when the temperature is below 20,…

Le_FryingPan
- 21
- 4
2
votes
2 answers
How to make PWM pulse with 20% duty cycle in AVR?
I want to generate a PWM wave in the PWM mode of timer0 in ATMEGA8 like the figure below:
It has a 20% duty cycle but it can't be implemented with PWM mode alone.
I have tried using the fast PWM mode in reversed mode and tried to check for the…

Freelancer
- 836
- 1
- 14
- 47
2
votes
1 answer
STM32F030 PWM Setup Issues
I'm trying to get PWM functioning on two pins of my STM32030R8T6, it's on a Nucleo development board and I'm using Keil. For learning, I've mostly been following the material on this website, but with adaptations as that site uses a different MCU.…

Unit_One
- 23
- 4
2
votes
0 answers
PWM on 16f error
My code will not compile because of this error in this function can anyone help
void SetDCPWM(unsigned int dutycycle) {
unsigned int local_dutycycle;
local_dutycycle = dutycycle;
CCPR1L = (dutycycle >>2);
CCP1CONbits.DC1B = local_dutycycle &…

Gooner1990
- 35
- 5
2
votes
2 answers
PIC (dsPIC33EP 512MU810) : High Speed PWM module
I'm trying to generate a 10% duty cycle-1kHz PWM with a clock at 80Mhz (F_osc) using the inbuilt (Hardware) high speed PWM.
According to the documentation,
Base Period (number for the PTPER) is calculated by
PTPER = F_osc / [(F_pwm) x…

Raaj
- 1,180
- 4
- 18
- 36
2
votes
1 answer
Strange PWM register on PIC
I have to work on some code for a dsPIC33FJ128MC804, and in the PWM library (ad hoc...) there is an assignment to DTCON1. The datasheet, however, doesn't mention this register at all, but only P1DTCON1 and P2DTCON1 for PWM module 1 and 2;…

Astrinus
- 412
- 9
- 19