Twenty Three Hundred
Dr Charles Martin
Semester 1, 2022
Little wires!
Assignment 2 presubmission!
Midsem feedback: aiming for Monday 9/5.
Quiz 2 opens next week!
What’s so hard about this?
communication is easy if both ends of the communication can share memory/registers
e.g., function calls, shared global variables (in the .data
section)
but most of the time that’s not the case
on a wire carrying electrical signals, what might difference look like? how many different ways could you achieve it?
there are a few fundamental “dimensions” to a given communications network
these are all (at least partially) orthogonal
the term node is used a lot when talking about networks
a node is anything which communicates on the network
lots of options here:
(anything else?)
In case you haven’t studied physics…
0
or 1
) and sometimes the
transitions are most important (rising/falling edge triggers)can we communicate with reaccs?
knock, knock!
who’s there?
a set of rules about what to “say” and how to understand the responses
in a computing context:
both sides must agree!
how are network “protocols” like social protocols? What happens when social protocols go wrong?
circuit-switched means nodes set up & use a dedicated connection (physical or logical)
example: phone lines in ye olden days—to route the phone call to the right place, the switchboard operator would literally make a physical connection between the caller & the receiver
packet-switched means data transmitted over the network is segmented into packets (or frames)
these packets contain both:
these days, most network protocols are packet-switched
this allows different nodes to share the same physical connections (multiplexing)
can we send a message in packets?
topology is the way that the nodes are connected to one another (both physically and logically)
there are several different ways to connect the nodes together, what are the consequences of different topologies?
how about sending a message to a specific node?
circuit-switched vs packet-switched?
serial | parallel |
---|---|
data is sent one-bit-at-a-time | multiple bits sent simultaneously (e.g. multiple wires) |
fewer bits sent per signal, but simpler | need to keep all the connections in sync |
There are two main approaches: synchronous and asynchronous. (See Sparkfun Serial Turorial)
Within the world of serial connections this looks something like this:
Synchronous:
Asynchronous:
What do we have to do?
Decide on a rate of bits-per-second (baudrate)
Send a start bit (set GPIO low)
Send the 8 bits of a byte (changing GPIO)
Send a stop bit (set GPIO high)
Not too hard, but we’ll need an oscilloscope to see what we are doing!
Let’s have a look at some bytes…
Are there any network protocols dedicated to musical instruments?
Can we set them up to work on a microbit?
“Musical Instrument Digital Interface” (1981)
A way to send musical “instructions” to a synthesiser.
E.g., (CC BY 2.0, Blurred Ren)
0
followed by a 7 bit number.Implementing a connection between two devices seems to be getting messy…
specific information about bit-level signals
special timing considerations
application-specific representations of information within and between bytes
Is there some way to separate concerns here?
The Open Systems Interconnection model (OSI model) is a conceptual model that characterizes and standardizes the communication functions of a telecommunication or computing system without regard to its underlying internal structure and technology (from Wikipedia)
standardised in 1977: 7 layer architecture, connection oriented
not often implemented in full, but concepts and terminology widely used.
What about synchronous? Did we miss that? And what else is on the microbit?
(NB: the pin terminology of SPI has changed recently to use more inclusive language).
full duplex, 4-wire, flexible clock rate
(SDI: “Serial Data In”, SDO: “Serial Data Out”, SCK: “Serial Clock”, CS: “Chip Select”)
Read/Write to peripherals (e.g., motion sensor) with I2C (Inter-Integrated Circuit Protocol)
Local area network (LAN) developed by Xerox in the 70’s
See Ben Eater’s youtube channel are great
Microbit has a “Bluetooth® 5.1, IEEE 802.15.4-2006, 2.4 GHz transceiver”
How does it work? Let’s look at section 6.18 of the nRF52833 manual!
this was a really high-level overview; a whirlwind tour
to go deeper, you could take COMP3310
Last time, we sent bytes manually with a timer.
The microbit has hardware to help us.
Let’s try the same thing with the UART hardware.
.set ADR_UART, 0x40002000
.set OFS_UART_STARTTX, 0x008
.set OFS_UART_TXDRDY, 0x11c
.set OFS_UART_ENABLE, 0x500
.set OFS_UART_PSEL_TXD, 0x50c
.set OFS_UART_TXD, 0x51c
.set OFS_UART_BAUDRATE, 0x524
.set OFS_UART_CONFIG, 0x56c
.type setup_output, %function
setup_output: @ Set RING0 (P0.2) to output
ldr r0, =ADR_P0
ldr r1, =OFS_GPIO_DIRSET
ldr r2, =(0b1 << 2)
str r2, [r0, r1]
bx lr
.size setup_output, . - setup_output
.type turn_on_ring_0, %function
turn_on_ring_0: @ Set RING0 (P0.2) to high
ldr r0, =ADR_P0
ldr r1, =OFS_GPIO_OUTSET
ldr r2, =(0b1 << 2)
str r2, [r0, r1]
bx lr
.size turn_on_ring_0, . - turn_on_ring_0
@ 0. Set RING0 (P0.2) to output and high
bl setup_output
bl turn_on_ring_0
@ 1. Clear UART config register
ldr r0, =ADR_UART
ldr r1, =OFS_UART_CONFIG
mov r2, 0x0 @ default values
str r2, [r0, r1]
@ 2. set baudrate
ldr r1, =OFS_UART_BAUDRATE
ldr r2, =0x00800000 @ 31250 baud
str r2, [r0, r1]
@ 3. set tx pin to RING0 (P0.2) - =(0x0 << 31 | 0x0 << 5 | 0x2) @ connect (clear 31), port 0, pin 2
ldr r1, =OFS_UART_PSEL_TXD
ldr r2, =(0x0 << 31 | 0x0 << 5 | 0x2) @ connected, port 0, pin 2
str r2, [r0, r1]
@ 4. enable UART
ldr r1, =OFS_UART_ENABLE
ldr r2, =4
str r2, [r0, r1]
@ 5. put byte to send into txd
ldr r1, =OFS_UART_TXD @ this is the transmit buffer -- the byte to actually send
mov r2, 0xFF @ <--- this is the byte to be sent!
str r2, [r0, r1]
@ 6. set starttx task
ldr r1, =OFS_UART_STARTTX
mov r2, 1
str r2, [r0, r1]
starttx
task has started, whenver you put a byte into UART_TXD
, that byte will be sent.TXDRDY
register to make sure previous byte has completed sending.TXDRDY
to generate an interrupt if you want