Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

PWM with NRF24LE1 (Part 6/14)

By Amanpreet Singh May 7, 2023

PWM with NRF24LE1

Have you ever thought that the phone light, when turned ON, is not always ON? It fluctuates with a frequency to save some energy which our eyes can’t sense. It’s a cool thing to save some battery but how is this done? The answer is PWM.
PWM is an important technique for producing analog voltages using digital voltages and controlling LEDs, DC, servo motor, etc.
In this article, we will discuss about generating PWM signal using NRF module.
 There are two ways to generate PWM signals with NRF2LE1:
1. Use delay to generate pulses of desired width.
2. Use inbuilt PWM hardware pins.
Prototype of NRF24LE1 Module based PWM Generator
Fig. 1: Prototype of NRF24LE1 Module based PWM Generator
We will cover both methods one by one.
First method:
This method is focused on using delay to control pulse width. Let’s understand it in simple steps.
1) First the output pin is made HIGH.
2) Then delay is given to hold output HIGH for specified time. This is done in order to generate a HIGH pulse.
3) The output pin is made LOW.
4) The delay is provided to hold output LOW.
5) Steps 1 to 4 are repeated.
The time period of the generated wave will be the sum of delay for HIGH pulse and delay for LOW pulse. Reciprocal of time will give us frequency of the produced signal. We can change the duty cycle by changing delay time of ON and OFF pulse. The delay can be created using inbuilt timers or we can use already defined delay functions. The delay functions are provided by inbuilt libraries.
Second Method:
In this method we will use inbuilt PWM functionality of NRF24LE1 to produce signals. This method is more convenient than the other as it removes reliability on delay functions. One restriction of this method is that the output of PWM signal can only be taken at PWM enabled pins.
Some features of inbuilt PWM are:
• Two channel output. PWM0 and PWM1
• Frequency range from 2 KHz to 254 KHz when MCU is provided 16MHz clock.
In NRF24LE1 there are two pins dedicated for PWM, PWM0 and PWM1. PWM0 is pin 3 of port 0 and PWM1 is pin4 of port 0.
The PWM is controlled through three registers:
Table Listing Registers of NRF24LE1 used for PWM Generation
Fig. 2: Table Listing Registers of NRF24LE1 used for PWM Generation
An image has been attached to understand the PWM frequency and duty cycle setting.
Simple steps to create PWM signals are:
1. Select period length by writing bit7:6 of PWMCON.
2. Choose prescaler for PWM frequency using bit5:2 of PWMCON.
3. Enable PWM0 or PWM1 using bit1 and bit0 of PWMCON.
4. Select Duty Cycle using PWMDC1 and PWMDC0.
A code has been written to understand the process of creating PWM.

Project Source Code

###

//Program to 
#include"reg24le1.h" // I/O header file for NRF24LE1
#include"hal_delay.h" // header file containing delay functions
 
// main function
void main()
{
int i = 0, j = 0; // loop variable
P0DIR = 0; // Port 0 as output
PWMCON = 0xfe; // enable PWM1
 
// infinte loop
while(1)
{
for(i= 0xff; i--; i > 0x00)
{
PWMDC1 = i ; // change duty cycle
delay_ms(10); // delay of 10 ms
}
 
 
}
 
}

###

 

Circuit Diagrams

Circuit-Diagram-NRF24LE1-Module-PWM-Generator

Project Video


Filed Under: Tutorials

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Voltage mode pushpull is a nonsense SMPS?
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe