Skip to content
  • Home
  • Account
  • Restricted content
  • OBEX
  • Chips Tips
  • Logout
  • Shop
  • Blog
Propeller OBEX
  • OBEX
  • Forum
Login
Propeller OBEX

Propeller 1

  • How to pause in PASM
  • How to choose between VAR and DAT
  • WAITPEQ and WAITPNE with PASM
  • IO pin manipulation using PASM
  • Control IO pins from any cog
  • 3D Models for Parallax Products
  • Implementing Abstract Data Structures with Spin Objects
  • Making in USA - The Parallax 8 core microcontroller
  • Simultaneous pin group control
  • Programming the FLiP module over WiFi
  • Keep any value in range
  • Handy Diagnostic Heartbeat
  • Customer Code Deployment in one click

Propeller 2

  • Generate a clock with any SmartPin
  • Floating point operators in SPIN2
  • 64/96/128-Bit Unsigned Integer Math
  • 3D Models for Parallax Products
  • DEBUG Plot Layer and Crop
  • Floating point
  • Getting Started Video Tutorials
  • Using the counter for timeouts
  • asmclk and the automatic clock setter
  • Sharing variables between SPIN2 and PASM2
  • Keep any value in range
  • Determine pin state - High, Low or Floating?
View Categories
  • Home
  • Docs
  • Chips Tips
  • Propeller 2
  • Generate a clock with any SmartPin

Generate a clock with any SmartPin

Reading Time: 1 min read

SPIN2

Introduction #

The Propeller 2 can set any of it's Smart IO pins to output a clock frequency without requiring any runtime resources.

Think of Smart Pins as mini microcontroller cores, and every one of the 64 IO's on the P2 microcontroller has one! It means you could set all 64 IO's to be outputting different clock frequencies; but here, let's start with just one!

The topic was discussed in our forums, and here follows a code snippet to demonstrate!

Code Snippets #

This code snippet demonstrates how to set a 3.7MHz clock signal outputting on the IO pin number declared as TEST_PIN.

Yes, it really is that simple! Set the pinstart command and the SmartPin will do the rest!

CON { System timing }

    _CLKFREQ = 180_000_000                                          ' Set the core system clock speed

CON { IO Pins }

    TEST_PIN = 0                                                    ' Set the IO pin to pin 0


PUB start() | freq                                                  ' Define a local variable called 
                                                                    '  "freq" to hold the frequency 
                                                                    '  you'd like to output.

    freq := 3_700_000                                               ' Set the frequency to 3.7MHz, 
                                                                    '  written in Hz as 3700000 or 
                                                                    '  3_700_000 for clarity.
                                                                    
                                                                    
    pinstart(TEST_PIN, p_nco_freq | p_oe, 1, freq frac clkfreq)     ' Start the SmartPin at the
                                                                    '  IO pin stored in "TEST_PIN" 
                                                                    '  in frequency output mode.
                                                                    '
                                                                    ' The command calculates the
                                                                    '  output frequency based on the
                                                                    '  core system clock "clkfreq" and
                                                                    '  the required frequency "freq".
    
    
    ' That's it! Continue the rest of your code here !


Resources #

Parallax Propeller 2 - Spin2 Language Documentation


Was this useful ?
Share This Article :
  • Facebook
  • X
  • LinkedIn
Still stuck? How can we help?

Still stuck? How can we help?

Updated on July 10, 2025
Floating point operators in SPIN2
Table of Contents
  • Introduction
  • Code Snippets
  • Resources

Copyright © 2025 - Parallax Inc.
599 Menlo Drive | Rocklin, CA 95765 | USA