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
      • Scamp Serial Comms
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
    • DataFlash
    • RS485
  • Create
    • Scamp Projects on Youtube
    • Prototyping >
      • Protoboards
      • Fabricating PCBs
      • Soldering
    • GPIO >
      • Adding Extra GPIO
      • 32-bit GPIO Module
      • Adding a Low Side Switch
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Memory >
      • Adding MRAM
      • AT24C256 EPROM Driver
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • FizzBuzz
    • Model Train Control
    • Adding a Real Time Clock
    • 1-D Pacman
  • Resources
  • Buy
  • Consulting
  • About

Mapping UARTs to Pins (Scamp1 and Scamp2)
​

Picture
On a Scamp1 or Scamp2 (only) the UARTs must be mapped to a pin on the connector. This can be any pin, with the exception of pins 7 and 8 for Rx and 4, 7, and 8 for Tx​. For example to map UART1's Rx to pin 4, place 4 on the stack and then call the word rx1pin:
4 rx1pin
Unfortunately there is a bug in the word to allocate Tx to a pin, so this has to be done manually. This is done by writing a function code to the appropriate register for a given pin (known as a RP pin). Tx1 has the function code 3 andTx2 has the function code 5. Use the following table for Forth commands to allocate Tx pins. 
Scamp PinRPxForth Command for Tx1Forth Command for Tx2
0 RP0 #3 $03d6 c! #5 $03d6 c!
1 RP1 #3 $03d7 c! #5 $03d7 c!
2 RB2 #3 $03d8 c! #5 $03d8 c!
3 RP3 #3 $03d9 c! #5 $03d9 c!
4 -
5 RP5 #3 $03db c! #5 $03db c!
6 RP6 #3 $03dc c! #5 $03dc c!
7 -
8 -
9 RP7 #3 $03dd c! #5 $03dd c!
10 RP13 #3 $03e3 c! #5 $03e3 c!
11 RP14 #3 $03e4 c! #5 $03e4 c!
12 RP15 #3 $03e5 c! #5 $03e5 c!

So for example, to allocate Tx1​ to Scamp pin 5:
#3 $03db c!

​Note that there is no requirement for 
both a receiver and transmitter to be allocated to pins. If you only need to receive data, you only need to allocate a receiver. Similarly, if you only need to transmit data, only a transmitter need be allocated.
On a Scamp3, the UARTs are already mapped to dedicated pins, so pin allocation is unnecessary. 

Learn : Interfacing : Serial Communication
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
      • Scamp Serial Comms
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
    • DataFlash
    • RS485
  • Create
    • Scamp Projects on Youtube
    • Prototyping >
      • Protoboards
      • Fabricating PCBs
      • Soldering
    • GPIO >
      • Adding Extra GPIO
      • 32-bit GPIO Module
      • Adding a Low Side Switch
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Memory >
      • Adding MRAM
      • AT24C256 EPROM Driver
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • FizzBuzz
    • Model Train Control
    • Adding a Real Time Clock
    • 1-D Pacman
  • Resources
  • Buy
  • Consulting
  • About