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 Pin | RPx | Forth Command for Tx1 | Forth 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