udamonic.com
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact

Random Number Generator
​

The PIC24 processor used in Scamp has a hardware Random Number Generator (RNG). This is a true random number, not a software-generated pseudo-random number.
​
The word random and places a 16-bit random number onto the stack. For example:
random
For a 32-bit random number, call random twice.

Device ID
​

The Microchip processor used in your Scamp has a Device ID register. This can be used by your software to determine the particular type of processor your code is running on, and also the silicon revision of that part.

The word devID and places onto the stack the processor's family/device code, and the revision number. For example:
hex
​​devID .s
gives the (hex) result 4c58 4. The 4c indicates that the device family is the PIC24FJ128GB204 family. 58 is a PIC24FJ64GB202 processor within that family. The silicon revision is 4. 

Processor Oscillator Frequency
​

The word Fcy will place the frequency (in kiloHertz) of the processor's primary oscillator onto the stack. This is an unsigned 16-bit value. 

On the Scamp3, the 16 MHz system clock is available on the main connector (label <CLK) as a reference, or for use as a clock source to external peripherals. 

Reference Oscillator
​

There is a 32 MHz reference oscillator that is available as an input to peripheral modules (such as the DSM Module). The Scamp3 word oscdiv takes a 16-bit value from stack, disables the oscillator momentarily, writes the divisor value to the appropriate register, and then re-enables the oscillator. A value of 0 gives a 32 MHz reference, 1 gives a 16 MHz reference, 2 gives an 8 MHz reference and so on, up to $ffff which gives a 490 Hz reference. 

For example, to set the frequency to 160 kHz:
#100 oscdiv

Learn : Extras : Processor Words
Site powered by Weebly. Managed by Hostwinds
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact