EmbeddedSoftware3
EmbeddedSoftware3
• The configuration of the clocks happens through the Reset and Clock Control
(RCC) registers
• located at a specific address within the internal peripheral region
• RCC configuration is vendor-specific, as it depends on the logic of the PLL
implemented in the microcontroller
• The registers are described in the documentation of the microcontroller
• often, example source code is provided by the chip manufacturer to demonstrate how to
properly configure the clocks on the microcontroller
CLOCK DISTRIBUTION
• Some pins have the possibility to measure the applied voltage dynamically,
• Assign a discrete number to the measured value, using an analog to digital signal
converter, or ADC
• This is very useful to acquire data from a wide range of sensors, capable of
conveying the information as output voltage, or simply using a variable resistor
• The configuration of the ADC subsystem may vary significantly across different
platforms
• ADCs on modern microcontrollers offer a wide range of configuration options
• Multiple features are available, such as DMA transfer of the acquired data, and monitoring
the signals in between two watchdog thresholds etc.
THE WATCHDOG
• Manage the access to a serial bus, which may consist of one or more wires,
• transporting the information in the form of electrical signals corresponding to logic levels, zeros and ones,
when associated with specific time intervals
• Protocols are different in the way they transmit and receive information on the data bus lines
• To transmit a byte, the transceiver encodes it as a bit sequence, which is synchronized with a clock
• The logic values of the bit are interpreted by the receiver reading its value on a specific front of the clock,
depending on the clock's polarity
• Each protocol specifies the polarity of the clock and the bit order required to transmit the data, which
can start with either the most or the least significant bit
CLOCK AND SYMBOL SYNCHRONIZATION
• In order for the receiving side to understand the message, the clock must be
synchronized between the parts
• The clock synchronization may be implicit, as in setting the same data rate to read and write
on the bus,
• or achieved by sharing the clock line from one side using an additional line, to explicitly
synchronize the transmit data rate
• Serial protocols that don't foresee shared clock lines are called asynchronous
• Symbol synchronization should instead be explicit.
• As we expect to send and receive information in byte form,
• the beginning of each eight bit sequence should be marked either through special preamble
sequences on the data line,
• or by turning the clock on and off at the right time
• The symbol synchronization strategy is defined by each protocol differently
BUS WIRING
• The number of lines needed to establish bidirectional communication depends on the
specific protocol too
• Since one wire can only transport one bit of information in one direction at a time,
• to achieve full-duplex communication, a transceiver should connect to two different wires for
transmitting and receiving data
• If the protocol supports half-duplex communication, it should instead provide a reliable
mechanism to regulate media access and switch between receiving and transmitting data on
the same wire
• Depending on the protocol:
• devices accessing the bus may either share a similar implementation and act as peers,
• or have different roles assigned when participating in the communication (Master/Slave)
• A serial protocol may foresee communication among more than two devices on the same
bus
• May be achieved by using extra slave selection wires, one per slave device sharing the same
bus,
• or by assigning logical addresses to each endpoint, and including the destination address for
the communication in the preamble of each transmission
Symbol
Protocol Number of wires Clock synchronization Bit order Communication mode
strategy
Configurable
One-to-one or one-to-many, single
UART-based Two (data RX/TX) Asynchronous start/stop bit, LSB first
point-to-point communication
parity bit
Three (master to slave One-to-many single master, multiple
MSB first or
SPI data, slave to master data, Shared through CLK Clock activation slave, using additional slave-selection
LSB first
clock) lines
Clock activation, One-to-many, master/slave with logic
Two (serial data and serial
I2C Shared through SCL with support for MSB first addresses, and dynamic multi-master
clock)
clock stretching selection
Synchronized with a
synchronization
Two (D+/D- half-duplex CRC / end of One host/multiple devices with device
USB pattern at the LSB first
differential signal) packet enumeration
beginning of data
transfer
Two (CAN-Hi and CAN-
Low), differential, half Start bit, CRC, and One-to-many multi-master with
CAN bus Asynchronous MSB first
duplex end sequence address-based master arbitration
• As UART has no clocks, UART adds start and stop bits that are being
transferred
• Helps receiving UART know when to start reading bits as the bits represent
the start and the end of the data packet
• When the receiving UART detect a start bit, it will read the bits at BAUD rate
• UART data transmission speed is referred to as BAUD Rate and is set
to 115,200 by default (BAUD rate is based on symbol transmission
rate, but is similar to bit rate)
• Both UARTs must operate at about the same baud rate.
ADVANTAGES OF USING UART