Quantcast
Viewing all articles
Browse latest Browse all 4894

Compute Module • PWM Not Working with dtoverlay=pwm-2chan on GPIO 18 (Raspberry Pi CM4)

Hello,

I am working on a project to test an LD (Laser Diode) component that requires PWM control. I am using a Raspberry Pi CM4 and attempting to enable PWM on GPIO 18.

Here’s what I’ve tried so far:

1. Manual Configuration
I successfully set GPIO 18 to PWM mode manually using the following command:
```bash
raspi-gpio set 18 a5
```
This worked, and I was able to control the PWM signal on GPIO 18 without issues.

2. Device Tree Configuration
I added the following line to `/boot/firmware/config.txt` to enable PWM automatically:
```txt
dtoverlay=pwm-2chan,pin=18,func=2
```
After rebooting, GPIO 18 does not work as a PWM pin. Instead, it remains configured as an `OUTPUT` with `pull=DOWN` (verified using `raspi-gpio get`).

3. Environment Details:
- Raspberry Pi CM4
- OS: Raspberry Pi OS


4. Additional Details:
- I have SPI and I2C enabled in `/boot/firmware/config.txt`:
```txt
dtparam=spi=on
dtparam=i2c=on
```
- No other overlays seem to conflict with GPIO 18.

Issue:
The manual configuration works perfectly, but the device tree overlay (`dtoverlay=pwm-2chan`) does not set GPIO 18 to ALT5 (PWM mode) as expected. How can I make the overlay work correctly?

Thank you for your help!

Statistics: Posted by dgy411852 — Fri Jan 03, 2025 8:17 pm



Viewing all articles
Browse latest Browse all 4894

Trending Articles