udamonic.com
  • Learn
    • What is a Scamp?
    • Getting Started
    • Learning Forth ... >
      • 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
    • Extras... >
      • Interrupts
      • Timers
      • Multitasking
      • Starting up with turnkey
      • Formatting Text on Screen
      • Changing the Prompt
      • Delays and Tick Count
      • Processor Words
      • Temperature Sensor
      • Using the LED Array
    • Interfacing... >
      • Input/Output
      • Analog Input
      • Serial Communication
      • PWM
      • I2C Overview
      • I2C Commands
      • SPI
      • Peripheral Pin Select
      • Timer Interrupts
      • Input Capture
      • Digital Signal Modulator
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Create
    • Adding LEDs
    • LED arc-welder effect
    • Measuring Temperature
    • Time Keeping
    • Model Train Control
    • FizzBuzz
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • Adding MRAM
    • Adding a 7 Segment Display
    • Adding a Touch LCD
    • Touch LCD GUI
    • Game of Pong
    • Adding an RTCC
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact

Mapping UARTs to Pins (Scamp1 and Scamp2)
​

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
  • Learn
    • What is a Scamp?
    • Getting Started
    • Learning Forth ... >
      • 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
    • Extras... >
      • Interrupts
      • Timers
      • Multitasking
      • Starting up with turnkey
      • Formatting Text on Screen
      • Changing the Prompt
      • Delays and Tick Count
      • Processor Words
      • Temperature Sensor
      • Using the LED Array
    • Interfacing... >
      • Input/Output
      • Analog Input
      • Serial Communication
      • PWM
      • I2C Overview
      • I2C Commands
      • SPI
      • Peripheral Pin Select
      • Timer Interrupts
      • Input Capture
      • Digital Signal Modulator
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Create
    • Adding LEDs
    • LED arc-welder effect
    • Measuring Temperature
    • Time Keeping
    • Model Train Control
    • FizzBuzz
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • Adding MRAM
    • Adding a 7 Segment Display
    • Adding a Touch LCD
    • Touch LCD GUI
    • Game of Pong
    • Adding an RTCC
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact