Skip to main content
Ctrl+K
BeagleBoard Documentation - Home
  • Introduction
  • Boards
  • Projects
  • Books
  • Accessories
    • About
    • Donate
    • GSoC
    • FAQ
  • OpenBeagle
  • Docs
  • Discord
  • Forum
  • BeagleBoard.org
  • Introduction
  • Boards
  • Projects
  • Books
  • Accessories
  • About
  • Donate
  • GSoC
  • FAQ
  • OpenBeagle
  • Docs
  • Discord
  • Forum
  • BeagleBoard.org

Section Navigation

  • simpPRU
    • simpPRU Basics
    • Build from source
    • Install
    • Language Syntax
    • IO Functions
    • Usage(simppru)
    • Usage(simppru-console)
    • simpPRU Examples
      • Delay example
      • Digital read example
      • Digital write example
      • HCSR04 Distance Sensor example (sending distance data to ARM using RPMSG)
      • Ultrasonic range sensor example
      • Sending state of button using RPMSG
      • LED blink on button press example
      • LED blink using for loop example
      • LED blink using while loop example
      • LED blink example
      • LED blink using hardware counter
      • Read hardware counter example
      • Using RPMSG to communicate with ARM core
      • Using RPMSG to implement a simple calculator on PRU
  • BB-Config
    • BB-Config Detail
    • Build from Source
    • Features
    • Version
  • Robotics Control Library
  • BeagleConnect Technology
Why are we doing this?

We believe in making computers open again to democratize technology and empower individuals and organizations to explore, experiment, and create without the constraints of proprietary systems.

What are we doing?

We design versatile and affordable single-board computers to provide developers, hobbyists, and educators with a platform for prototyping, experimentation, and production of embedded systems. Our comprehensive documentation, tutorials, and vibrant online community support users in their projects and foster knowledge sharing.

How are we doing it?

Through open-source hardware designs, diverse software support, and active community engagement, we enable users to customize, innovate, and collaborate effortlessly in embedded computing.

Support us

The BeagleBoard.org Foundation is a Michigan, USA-based 501(c)(3) non-profit corporation existing to provide education in and collaboration around the design and use of open-source software and hardware in embedded computing.

Become a Patreon Sponsor on GitHub
  • Projects
  • simpPRU Examples
  • LED blink...

LED blink using hardware counter#

LED blink using hardware counter

Code#

while : true {
    start_counter();
    while : read_counter() < 200000000 {
        digital_write(P1_31, true);
    }
    stop_counter();

    start_counter();
    while : read_counter() < 200000000 {
        digital_write(P1_31, false);
    }
    stop_counter();
}
  • Following code works on PocketBeagle, to use on other boards, please change the pins accordingly.

Explanation#

This code runs a never ending while loop, since it is while : true. Inside while it starts the counter, then in a nested while loop, which runs as long as read_counter returns values less than 200000000, so for 200000000 cycles, HIGH is written to header pin P1_31, and after the while loop ends, the counter is stopped.

Similarly counter is started again, which runs as long as read_counter returns a value less than 200000000, so for 200000000 cycles, LOW is written to header pin P1_31, and after the while loop ends, the counter is stopped.

This process goes on endlessly as it is inside a never ending while loop. Here, we check if read_counter is less than 200000000, as counter takes exactly 1 second to count this much cycles, so basically the LED is turned on for 1 second, and then turned off for 1 second. Thus if a LED is connected to the pin, we get a endlessly blinking LED.

previous

LED blink example

next

Read hardware counter example

Outstanding todo items
On this page
  • Code
  • Explanation
Edit on OpenBeagle
Show Source
Download PDF
Provide Feedback
Feedback
Generate OpenBeagle Issue
Discuss on Forum

BeagleBoard.org is all about being open, please discuss in public on our forum!

© Copyright 2024, BeagleBoard.org Foundation.

Last updated on Dec 07, 2024.