L26_Sync_Serial

L26_Sync_Serial - Intro to Synchronous Serial ECET 209 –...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Intro to Synchronous Serial ECET 209 – Lecture 26 Introduction to Microcontrollers Analog and Digital Converter Input and Output Requirements 12-Bits for the ADC & 8-Bits for the DAC micro ADC => 20 total Bits DAC Analog and Digital Converter Input and Output Requirements 12-Bits for the ADC & 8-Bits for the DAC micro ADC => 20 total Bits DAC 2 1/2 PORTS of total I/O How can we reduce the number of I/O port pins required? If you Remember… • Way back at the beginning of the class – Discussed the I/O of the microcontroller – 8-Bit PARALLEL ports used for I/O – 2-Bit SERIAL port that was used to communicate with the PC • Actually send 10-bits of data – 1 start bit – 1 stop bit – 8 data bits If you Remember… • Way back at the beginning of the class – Discussed the I/O of the microcontroller – 8-Bit PARALLEL ports used for I/O – 2-Bit SERIAL port that was used to communicate with the PC • Actually send 10-bits of data – 1 start bit – 1 stop bit – 8 data bits Serial Port Communications • Two basic types of serial communications – Asynchronous serial communications • Based on baud rate ( 1 / bit time ) • Requires both devices to be set to the same rate – Synchronous serial communications • Based on an external clock signal • Clock signal “syncs” the two devices Synchronous Serial • Many devices are using several bits for serial data transfer instead of parallel interfaces – Digital to Analog Converter ( MAX 512 ) – 10-Bit ADC ( MAX1243 ) – Using a 3-wire serial interface Digital to Analog Converter micro DAC Digital to Analog Converter micro DAC Digital to Analog Converter micro DAC Open for ??? MAX512 Analog to Digital Converter micro ADC Analog to Digital Converter micro ADC Analog to Digital Converter micro ADC Open for ??? MAX1243 10-Bit ADC In Groups • Look through the Max1243 Data Sheet and create the solution steps to create a function to interface with the ADC MAX1243 10-Bit ADC Algorithm for MAX1243 • • • • • • • • • Take the Chip Select Line Low Wait for EOC Take the CLK High Take CLK back Low Take the CLK High Read the Data bit Take the CLK Low … Bring the Chip Select Line High Reading Serial Data 7 6 5 4 3 2 1 0 Reading Serial Data • When Reading Serial Data, it is very common to use a “shifting” operation – – – – – Get the 1st bit of data Shift the data (inside a variable) Get the 2nd bit of data Shift the data … Reading Serial Data (MSB 1st) 7 7 6 5 4 7 6 7 6 5 7 6 5 4 3 2 1 0 Reading Serial Data (LSB 1st) 0 1 2 3 0 1 2 0 1 0 7 6 5 4 3 2 1 0 Reading Serial Data • Word of Caution ( software guideline ) – Do not shift the data until you are ready to read the next bit • Only shift the data before reading the next bit • Not after reading – Shifting data after reading the bit may result in shifting a data bit out of the variable boundaries Reading Serial Data • Use an IF construct to test the incoming serial bit of data if ( DOUT != 0 ) { } • If the bit of data is “set” use a Bitwise OR to set the corresponding bit in the variable Reading Serial Data (MSB 1st) • Use an IF construct to test the incoming serial bit of data if ( DOUT != 0 ) { value = value | 0x01; } • If the bit of data is “set” use a Bitwise OR to set the corresponding bit in the variable Reading Serial Data (LSB 1st) • Use an IF construct to test the incoming serial bit of data if ( DOUT != 0 ) { value = value | 0x80; } • If the bit of data is “set” use a Bitwise OR to set the corresponding bit in the variable Reading Serial Data • Use a For Loop – Shift the variable to make room for the new data bit that is going to be read – Read the data bit – Work the Clock ...
View Full Document

This note was uploaded on 02/22/2012 for the course ECET 209 taught by Professor Richardson during the Fall '08 term at Purdue.

Ask a homework question - tutors are online