


















































Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!



















































▪ Concepts
▪ Tools
▪ Software: polling, interrupts and buffering
▪ Launched in 1977
▪ Constraints: Reliability, power, size, weight, reliability, reliability, etc.
▪ “Uplink communications is via S-band (16-bits/sec command rate) while an X-band transmitter provides
downlink telemetry at 160 bits/sec normally and 1.4 kbps for playback of high-rate plasma wave data. All
data are transmitted from and received at the spacecraft via the 3.7 meter high-gain antenna (HGA).”
http://voyager.jpl.nasa.gov/spacecraft/index.html
▪ Uplink – to spacecraft
▪ Downlink – from spacecraft
▪ Parallel data lines, read and write lines between MCU and each peripheral
MCU
Peripheral
WrRd Data
Peripheral
Data Rd Wr
Peripheral
Data
Rd Wr
Peripheral
Data
Rd Wr
Clk
D Q
D
D Q
D
D Q
D
D Q
D
Serial
Data Out
Parallel Data In
Clk
D Q
D
D Q
D
D Q
D
D Q
D
Serial
Data In
Parallel Data Out
Clock
Serial Data
Data Sampling Time at Receiver
▪ Allows simultaneous send and receive full-duplex communication
MCU
Peripheral
DOut
Select
ClkDIn
Peripheral
DOut
Select
DIn
Peripheral
DOut
Select
DIn
Peripheral
DOut
Select
DIn
T
bit
*1.
Data bits
Data Sampling
Time at Receiver
T
bit
*2.
T
bit
*3.
T
bit
*4.
T
bit
*5.
T
bit
*6.
T
bit
*7.
T
bit
*8.
T
bit
*9.
Time Zero
Start bit
Stop bit
▪ Data frame fields
▪ Start bit (one bit)
▪ Data (LSB first or MSB, and
size – 7, 8, 9 bits)
▪ Optional parity bit is used to make total number of ones in data even or odd
▪ Stop bit (one or two bits)
▪ All devices must use the same communications parameters
▪ E.g. communication speed (300 baud, 600, 1200, 2400, 9600, 14400, 19200, etc.)
▪ Sophisticated network protocols have more information in each data frame
▪ Medium access control – when multiple nodes are on bus, they must arbitrate for permission to transmit
▪ Addressing information – for which node is this message intended?
▪ Larger data payload
▪ Stronger error detection or error correction information
▪ Request for immediate response (“in-frame”)
Message
Data bits Start bit Stop bit
▪ $150 (www.saelae.com)
▪ Plugs into PC’s USB port
▪ Decodes SPI, asynchronous serial, I2C, 1-
Wire, CAN, etc.
SOFTWARE STRUCTURE – HANDLING
ASYNCHRONOUS COMMUNICATION
▪ Main program (and subroutines it calls)
▪ Transmit ISR – executes when serial interface is ready to
send another character
▪ Receive ISR – executes when serial interface receives a
character
▪ Error ISR(s) – execute if an error occurs
▪ Solution: circular queue with head and tail pointers
▪ One for tx, one for rx
Serial
Interface
tx_isr
rx_isr
send_string get_string
Main Program or
other threads
▪ tx ISR unloads tx_q
▪ rx ISR loads rx_q
▪ Use % (modulus, remainder) operator if queue size is not power of two
▪ Use & (bitwise and) if queue size is a power of two
write data
to tail
read data
from head
older
data
newer
data
Serial
Interface
tx_isr
rx_isr
get_string
send_string
int queue_init(Queue *queue, uint32_t size) {
queue->data = (uint8_t*)malloc(sizeof(uint8_t) * size);
queue->head = 0;
queue->tail = 0;
queue->size = size;
// If malloc returns NULL (0) the allocation has failed.
return queue->data != 0;
}
int queue_is_full(Queue *queue) {
return ((queue->tail + 1) % queue->size) == queue->head;
}
int queue_is_empty(Queue *queue) {
return queue->tail == queue->head;
}
int queue_enqueue(Queue *queue, uint8_t item) {
if (!queue_is_full(queue)) {
queue->data[queue->tail++] = item;
queue->tail %= queue->size;
return 1;
} else {
return 0;
}
}
int queue_dequeue(Queue *queue, uint8_t *item) {
if (!queue_is_empty(queue)) {
*item = queue->data[queue->head++];
queue->head %= queue->size;
return 1;
} else {
return 0;
}
}