Professional Documents
Culture Documents
INTERFACES OF MICROCONTROLLER
Lecturer: DSc, dosent Utkir Khamdamov
E-mail: utkir.hamdamov@mail.ru
Resources
• https://www.mikroe.com/ebooks/architecture-and-program
ming-of-8051-mcus
• https
://learn.mikroe.com/ebooks/8051programming/chapter/2-7
-uart-universal-asynchronous-receiver-and-transmitter
/
• KRISHNA KANT
• MICROPROCESSORS AND MICROCONTROLLERS:
ARCHITECTURE, PROGRAMMING AND SYSTEM
DESIGN
Microcontroller Architecture
Serial Interfaces of Microcontroller
UART
Universal SPI
Asynchronous Serial
Receiver and Peripheral Interface
Transmitter
Application of UART
UART pins of Microcontroller
• AVR ATmega32
• UART (RxD) – прием данных
контакт PDO
• UART (TxD) –передача
данных контакт PD1
UART serial port
• UART
• serial port
• full-duplex port
• transmit and receive data simultaneously
• different baud rates
• Programmer has to do select
• serial port mode
• baud rate
• SBUF
• serial data transmit is nothing but writing to the SBUF register,
while data receive represents reading the same register
UART Data Format
SPI UART
Transfer rate 1-20 MHz 9 – 56 kHz
Usage field High speed Keyboard,
devices Character LCD / Monitor
UART SCON Register
• Serial port must be configured
• determine how many bits is contained in one serial “word”
• baud rate and
• synchronization of transmission
• RECEIVE – Data receive through the RXD pin starts when: bit REN=1 and RI=0.
When all 8 bits have been received, the RI bit of the SCON register is automatically
set indicating that one byte receive is complete.
UART Serial Port Mode 1
• In mode 1, 10 bits are
transmitted through the TXD pin
or received through the RXD pin
• a START bit (always 0),
• RECEIVE – The START bit (logic zero (0)) on the RXD pin initiates data receive, when: bit
REN=1 and bit RI=0. The RI bit is automatically set upon data reception is complete.
• RECEIVE – The START bit (logic zero (0)) on the RXD pin initiates data receive, when:
bit REN=1 and bit RI=0. The RI bit is automatically set upon data reception is complete.
Multiprocessor Communication
SERIAL PERIPHERAL INTERFACE
(SPI)
Application of SPI
ATmega16/32 SPI Pins
SPI - Serial Peripheral Interface
• SPI (Serial Peripheral
Interface) - serial
synchronous four-
wire data interface
SPI - Serial Peripheral Interface
• MISO (Master In Slave Out)
• Master receives data, and the Slave transmits data
• SCK (Shift Clock)
• Only the Master generates synchronization pulses, which are used by the slaves..
• SS (Slave Select)
• The master can select the slave through this contact.
SPI Data transfer:
Normal SPI mode (buffer out of use)
• Data written to the SPI data register SPDR is automatically transferred to
an 8-bit Shift register.
• SPI clock generator is enabled and serial data appears on the MOSI pin.
• An initial delay may occur for the sake of synchronization with the main
oscillator.
SPI Data transfer:
Enhanced SPI mode (buffer in use)
• 1.Data written to the SPI data register SPDR is automatically transferred to
the buffer, which causes the WCOL bit to be set
• 2.Data transferred to shift register
• 3. While one byte transmit is in progress, the next byte to transmit may be
written to the SPDR register.
SPI Special Function Registers
• The SPI system is under control of 3 special function
registers
• SPDR – data register
• Bit 6 – SPE: SPI communication enable bit (between MC pin and Port pin)
• 1 = SPI communication enable. 0 = SPI communication disable.
• Bit 5 – DORD: SPI Data ordination bit
• 1 = LSB first. 0 = MSB first
• Bit 4 – MSTR: mode selection bit (Master/Slave)
• 1 = Master. 0 = Slave.
CPHA=0
CPHA=1
Baud rate of SPI (SPCR)
• SPR1: SPR0 – Baud rate or clock cycle frequency selection bit.
• where Fosc MCU clock cycle frequency.