Lab 7 Report EEL4742 (1)
.pdf
keyboard_arrow_up
School
University of Central Florida *
*We aren’t endorsed by this school
Course
4742
Subject
Electrical Engineering
Date
Apr 3, 2024
Type
Pages
21
Uploaded by BaronOxideSandpiper36
1 Lab 7 Report Davi Dantas Da646168@ucf.edu EEL4742C - 419: Embedded Systems
2 Introduction For this lab, I improved my understanding of I2C. How to implement I2C and
use itto have communication between the microcontroller MSP430FR6989 and PC. This lab also required me to use the family guide and gain more familiarity with the manuals as well as how to configure the light sensor in order to have the readings as required. Part 7.1
For the first part of the lab, I implemented communication so the Master could read the Device and Manufacture ID in a continuous loop. #include <msp430fr6989.h> #include <string.h> #include <stdlib.h> #define FLAGS UCA1IFG // Contains the transmit & receive flags #define RXFLAG UCRXIFG // Receive flag #define TXFLAG UCTXIFG // Transmit flag #define TXBUFFER UCA1TXBUF // Transmit buffer #define RXBUFFER UCA1RXBUF // Receive buffer void Initialize_UART
(
void
); // Initialize UART function void uart_write_char
(
unsigned char ch); // Write UART function void uart_write_uint16
(
unsigned int
); // Display digits void uart_write_string
(
unsigned char str[]); void Initialize_I2C
(
void
); int i2c_read_word
(
unsigned char i2c_address, unsigned char i2c_reg, unsigned int *data); int i2c_write_word
(
unsigned char i2c_address, unsigned char i2c_reg, unsigned int data); int i2c_read_word
(
unsigned char
, unsigned char
, unsigned int *); int i2c_write_word
(
unsigned char
, unsigned char
, unsigned int
); void main
() { WDTCTL = WDTPW | WDTHOLD; PM5CTL0 &= ~LOCKLPM5; volatile unsigned int i; unsigned int data = 0xABCD; Initialize_UART(); Initialize_I2C(); while (1) { i2c_read_word(0x22, 0x7E, &data); // Read the manufacturer ID uart_write_string(
"\r\nThe manufacturer ID is: "
); uart_write_uint16(data); // Write value to serial port i2c_read_word(0x22, 0x7F, &data); // Read the Device ID uart_write_string(
"\r\nThe Device ID is: "
); uart_write_uint16(data); // Write value to serial port for (i = 0; i < 100000; i++) {} } }
3 // Configure UART to the popular configuration // 9600 baud, 8-bit data, LSB first, no parity bits, 1 stop bit // no flow control, oversampling reception // Clock: SMCLK @ 1 MHz (1,000,000 Hz) void Initialize_UART
(
void
) { // Configure pins to UART functionality P3SEL1 &= ~(BIT4 | BIT5); P3SEL0 |= (BIT4 | BIT5); // Main configuration register UCA1CTLW0 = UCSWRST; // Engage reset; change all the fields to zero // Most fields in this register, when set to zero, correspond to the // popular configuration UCA1CTLW0 |= UCSSEL_2; // Set clock to SMCLK // Configure the clock dividers and modulators (and enable oversampling) UCA1BRW = 6; // divider // Modulators: UCBRF = 8 = 1000 --> UCBRF3 (bit #3) // UCBRS = 0x20 = 0010 0000 = UCBRS5 (bit #5) UCA1MCTLW = UCBRF3 | UCBRS5 | UCOS16; // Exit the reset state UCA1CTLW0 &= ~UCSWRST; } // The function returns the byte; if none received, returns null character unsigned char uart_read_char
(
void
) { unsigned char temp; // Return null character (ASCII=0) if no byte was received if ((FLAGS & RXFLAG) == 0) return 0; // Otherwise, copy the received byte (this clears the flag) and return it temp = RXBUFFER; return temp; } void uart_write_char
(
unsigned char ch) { // Wait for any ongoing transmission to complete while ((FLAGS & TXFLAG) == 0) {} // Copy the byte to the transmit buffer TXBUFFER = ch; // Tx flag goes to 0 and Tx begins! } void Initialize_I2C
(
void
) { // Configure the MCU in Master mode // Configure pins to I2C functionality // (UCB1SDA same as P4.0) (UCB1SCL same as P4.1) // (P4SEL1=11, P4SEL0=00) (P4DIR=xx) P4SEL1 |= (BIT1 | BIT0); P4SEL0 &= ~(BIT1 | BIT0); // Enter reset state and set all fields in this register to zero UCB1CTLW0 = UCSWRST; // Fields that should be nonzero are changed below // (Master Mode: UCMST) (I2C mode: UCMODE_3) (Synchronous mode: UCSYNC) // (UCSSEL 1:ACLK, 2,3:SMCLK) UCB1CTLW0 |= UCMST | UCMODE_3 | UCSYNC | UCSSEL_3;
4 // Clock frequency: SMCLK/8 = 1 MHz/8 = 125 KHz UCB1BRW = 8; // Chip Data Sheet p. 53 (Should be 400 KHz max) // Exit the reset mode at the end of the configuration UCB1CTLW0 &= ~UCSWRST; } void uart_write_uint16
(
unsigned int n) { int digit; // Variable to hold each digit of the number // Extract and transmit each digit of the number // Check if the number is greater than or equal to 10000 if (n >= 10000) { digit = (n / 10000) % 10; // Extract the ten-thousands digit uart_write_char(
'0' + digit); // Transmit the ten-thousands digit } else if (n >= 1000) { // Check if the number is greater than or equal to 1000 digit = (n / 1000) % 10; // Extract the thousands digit uart_write_char(
'0' + digit); // Transmit the thousands digit } else if (n >= 100) { // Check if the number is greater than or equal to 100 digit = (n / 100) % 10; // Extract the hundreds digit uart_write_char(
'0' + digit); // Transmit the hundreds digit } else if (n >= 10) { // Check if the number is greater than or equal to 10 digit = (n / 10) % 10; // Extract the tens digit uart_write_char(
'0' + digit); // Transmit the tens digit } else { // For numbers less than 10 digit = n % 10; // Extract the ones digit uart_write_char(
'0' + digit); // Transmit the ones digit } } // Read a word (2 bytes) from I2C (address, register) int i2c_read_word
(
unsigned char i2c_address, unsigned char i2c_reg, unsigned int *data) { unsigned char byte1, byte2; // Initialize the bytes to make sure data is received every time byte1 = 111; byte2 = 111; //********** Write Frame #1 *************************** UCB1I2CSA = i2c_address; // Set I2C address UCB1IFG &= ~UCTXIFG0; UCB1CTLW0 |= UCTR; // Master writes (R/W bit = Write) UCB1CTLW0 |= UCTXSTT; // Initiate the Start Signal while ((UCB1IFG & UCTXIFG0) == 0) {} UCB1TXBUF = i2c_reg; // Byte = register address while ((UCB1CTLW0 & UCTXSTT) != 0) {} if ((UCB1IFG & UCNACKIFG) != 0) return -1; UCB1CTLW0 &= ~UCTR; // Master reads (R/W bit = Read) UCB1CTLW0 |= UCTXSTT; // Initiate a repeated Start Signal //**************************************************** //********** Read Frame #1 *************************** while ((UCB1IFG & UCRXIFG0) == 0) {} byte1 = UCB1RXBUF; //**************************************************** //********** Read Frame #2 *************************** while ((UCB1CTLW0 & UCTXSTT) != 0) {} UCB1CTLW0 |= UCTXSTP; // Setup the Stop Signal
5 while ((UCB1IFG & UCRXIFG0) == 0) {} byte2 = UCB1RXBUF; while ((UCB1CTLW0 & UCTXSTP) != 0) {} //**************************************************** // Merge the two received bytes *data = ((byte1 << 8) | (byte2 & 0xFF)); return 0; } // Write a word (2 bytes) to I2C (address, register) int i2c_write_word
(
unsigned char i2c_address, unsigned char i2c_reg, unsigned int data) { unsigned char byte1, byte2; byte1 = (data >> 8) & 0xFF; // MSByte byte2 = data & 0xFF; // LSByte UCB1I2CSA = i2c_address; // Set I2C address UCB1CTLW0 |= UCTR; // Master writes (R/W bit = Write) UCB1CTLW0 |= UCTXSTT; // Initiate the Start Signal while ((UCB1IFG & UCTXIFG0) == 0) {} UCB1TXBUF = i2c_reg; // Byte = register address while ((UCB1CTLW0 & UCTXSTT) != 0) {} while ((UCB1IFG & UCTXIFG0) == 0) {} //********** Write Byte #1 *************************** UCB1TXBUF = byte1; while ((UCB1IFG & UCTXIFG0) == 0) {} //********** Write Byte #2 *************************** UCB1TXBUF = byte2; while ((UCB1IFG & UCTXIFG0) == 0) {} UCB1CTLW0 |= UCTXSTP; while ((UCB1CTLW0 & UCTXSTP) != 0) {} return 0; } void uart_write_string
(
unsigned char str[]) { int index; // Reads the string until it is NULL for (index = 0; index < strlen
(str) + 1; index++) { uart_write_char(str[index]); } } The address is chosen by the schematic given in binary, you can also use hex 0x44 . The Manufacture ID is 5449(hex) so it will display 21577 in decimal. The Device ID is 3001 (hex) , it will covert to 12289 in decimal.
6 Part 7.2
For this code, I needed to configure the light sensor in order to provide the readings according to the given specifications. As light got dimmer or brighter, the reading clearly change as expected. #include <msp430fr6989.h> #include <string.h> #include <stdlib.h> // UART definitions #define FLAGS UCA1IFG // Contains the transmit & receive flags #define RXFLAG UCRXIFG // Receive flag #define TXFLAG UCTXIFG // Transmit flag #define TXBUFFER UCA1TXBUF // Transmit buffer #define RXBUFFER UCA1RXBUF // Receive buffer // Function prototypes void Initialize_UART
(
void
); void uart_write_char
(
unsigned char ch); void uart_write_uint16
(
unsigned int
); void uart_write_string
(
unsigned char str[]); void Initialize_I2C
(
void
); int i2c_read_word
(
unsigned char
, unsigned char
, unsigned int
*); int i2c_write_word
(
unsigned char
, unsigned char
, unsigned int
); // Main function void main
() { WDTCTL = WDTPW | WDTHOLD; PM5CTL0 &= ~LOCKLPM5; volatile unsigned int i; int j = 1; unsigned int data; Initialize_UART(); Initialize_I2C(); while (1) { i2c_write_word(0x44, 0x01, 0x7604); uart_write_string(
"\r\nLux value: "
); i2c_read_word(0x44, 0x00, &data); uart_write_uint16(data * 1.28); uart_write_string(
"\r\n#"
); uart_write_uint16(j); j++; for (i = 0; i < 60000; i++) {} } } // Configure UART to the popular configuration // 9600 baud, 8-bit data, LSB first, no parity bits, 1 stop bit // no flow control, oversampling reception // Clock: SMCLK @ 1 MHz (1,000,000 Hz) void Initialize_UART
(
void
) { // Configure pins to UART functionality P3SEL1 &= ~(BIT4 | BIT5); P3SEL0 |= (BIT4 | BIT5);
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
An SN74AS138 output cannot (reliably)drive an SN74AC08 input when both chips have VCC=4.5 V. Why not?
arrow_forward
electronics engineering
What are IC Voltage regulators? State the different IC voltage regulators and its operation.
arrow_forward
I need the answer as soon as possible
arrow_forward
Briefly explain the basic concepts of transistors and diodes can function as logic gates!
Please Answer with explanation and full Step thank u.... I'm needed in 30-60 minutes...
arrow_forward
8. An 8-bit ADC with a 10.0 V reference has an input of 3.637 V
i. Determine the digital output.
ii.
What range of input voltages would produce this same output?
iii.
Suppose the output of the ADC is 101101012, calculate the input voltage.
arrow_forward
A chopper may be thought as a
O a. DC equivalent of an induction motor
O b. DC equivalent of an AC transformer
O c. Diode rectifier
O d. Inverter with DC input
arrow_forward
8. PCM is an example of.
A. Digital data to digital signal
B. Digital data to analog signal
C. Analog data to analog signal
D. Analog data to digital signal
arrow_forward
b) AND C)
arrow_forward
For the circuit shown below, identify the logic function performed by it. Also determine the
high level fan-out, if Rp(pull-up resistor) = 10 ks. Compute the maximum value of Rp for
a fan-out of 5. Assume that input diode has a leakage current of 100 μA.
Given: V₁ = 0.7V, V (forward voltage drop) = 0.8V, VBE(cut-in) = 0.5V, VCE(sat) = 0.2V. Transistor
leakage current is negligible.
1H
Ao-
Во
Co
D₂
D
20 ΚΩ
P₁
P₂
10 kQ
D₁
www
10 ΚΩ
>+5V
Rp
Іон
arrow_forward
An Intel 8085 processor is executing the program
given below.
MVI A, 10H
MVI B, 10H
BACK NOP
:
ADD B
RLC
JNC BACK
HLT
The number of times that the operation NOP will
be executed is equal to
arrow_forward
Discuss the pin diagram of any logic gate? Explain how the NAND gate can be used to derive the other logic gates.
Discuss the application of diode as positive series clipper positively biased with ideal diode, practical silicon diode. Draw the neat waveform diagrams.
Elaborate the working of half wave rectifier with neat diagram and waveforms. Determine the peak output voltage and current in the 4 kW load resistor connected to the output terminals of full wave bridge rectifier, if the transformer secondary voltage is 28 Vrms. Use the practical silicon diode model.
Discuss the types of transformers with their applications. Explain with a neat diagram an isolation transformer used for electrical power transmission. Also explain the transformation ratio.
Explain the difference between single phase and three phase induction motors with their application in detail. Determine the back emf generated in the dc shunt motor if it takes 250 V, 41 A current while running at full load. Assume…
arrow_forward
In a simple, three-phase voltage-source inverter of the form shown in
Fig. 8.18, the direct voltage va in the link is 550 V. The frequency of the
inverter output is 200 Hz. Determine:
(a) the rms value of the fundamental component of the output voltage,
line to line and line to neutral, and
(b) the rms value of the actual output voltage line to line and line to
neutral.
arrow_forward
Use the following figure to answer the following question:
In this circuit (inverter), the half-wave, controlled rectifier is connected to a 200 V
source (VRMS(p) = 200 V). The PWM controller works with a sampling (switching)
frequency equal to 1250 Hz to generate a 120 V(RMS) and 60 Hz output voltage.
1
s1
S2
V1
C1
100uF
+ Vout-
200 V
35 Hz
S3
S4
PWM Controller
Assume firing angle equal to 10 deg. and find the on-time duration (TOn) for the
PWM waveform when the output sinusoidal waveform has an instantaneous
amplitude equal to 150 V.
arrow_forward
The gate of a JFET is . . biased
Select one:
a. forward
b. reverse as well as forward
c. none of the above
d. reverse
arrow_forward
3b
will upvote for correct answers
arrow_forward
B6
arrow_forward
Please may you give the solution to this computer science question!
Thank you
arrow_forward
Draw logic diagram for half adder and full adder circuit using Logisim Software
arrow_forward
) The input waveforms in are applied to logic circuit in figure below. Determine the output
waveforms.
B
G2
C
C
D
D
E
arrow_forward
The required 7-segmrnt decoder should have 3-inputs (which are the bits of the binary number desired to
be designed, call them A,B,C), and 7 outputs (the 7 segments of the display unit which are a, b, c, d, e, f
& g).
8.
gf a b
t la Ob
d Dp
e d8c Dp
The 7-segment to be used is of common anode type. Consequently, any segment will be ON if its input
is Low, meaning that for displaying 0 the segments inputs (a,b,c,d,e,f.g) should be (0000001), or g will be
OFF while all the others are ON.
1- Make a table explaining the inputs and the corresponding outputs for the 6 combinations input
(000.101), assuming the other two combinations as don't care.
2-
Find the output as a function of the inputs (A,B,C) using K-map to minimize the expressions
3-
Show your design using 2-input, and 3-input NAND gates, and inverter.
arrow_forward
Explain minimum 5 Boolean laws applicable in case of digital circuits.Explain N type semiconductors
arrow_forward
Problem #2:
Apply the input waveforms A, B and C of the figure below to a NOR gate and draw the output
waveform.
A
B
C
arrow_forward
DIsassemble the following MIPS 32-bit hexadecimal instruction written as addr:instr
60005000 : 0c000020
arrow_forward
Q1// What are the difference between Logic Devices and Programmable
Logic Devices?
Q2// Explain the advantage's of Programmable Logic Devices?
Q3// List the disadvantages of Fixed function logic devices.
Q4// Compare between Logic Devices and Programmable Logic Devices?
arrow_forward
Q2/A) Design 8x1 multiplexer using 2x1 multiplexer?
Q2 B)Simplify the Logic circuit shown below using K-map then draw the
Simplified circuit?
Q2/C) design logic block diagram for adding 12 to 5 using full adder showing
the input for each adder?
arrow_forward
Find transition table and equations used.
arrow_forward
Solve in 8086 microprocessor
arrow_forward
i need the answer quickly
arrow_forward
Derive the state table and the state graph for the following logic circuit:
A'
B'
B
DA
Clock
Clock
X B'
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:PEARSON
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:9781337900348
Author:Stephen L. Herman
Publisher:Cengage Learning
Programmable Logic Controllers
Electrical Engineering
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:9780078028229
Author:Charles K Alexander, Matthew Sadiku
Publisher:McGraw-Hill Education
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:9780134746968
Author:James W. Nilsson, Susan Riedel
Publisher:PEARSON
Engineering Electromagnetics
Electrical Engineering
ISBN:9780078028151
Author:Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:Mcgraw-hill Education,
Related Questions
- Briefly explain the basic concepts of transistors and diodes can function as logic gates! Please Answer with explanation and full Step thank u.... I'm needed in 30-60 minutes...arrow_forward8. An 8-bit ADC with a 10.0 V reference has an input of 3.637 V i. Determine the digital output. ii. What range of input voltages would produce this same output? iii. Suppose the output of the ADC is 101101012, calculate the input voltage.arrow_forwardA chopper may be thought as a O a. DC equivalent of an induction motor O b. DC equivalent of an AC transformer O c. Diode rectifier O d. Inverter with DC inputarrow_forward
- 8. PCM is an example of. A. Digital data to digital signal B. Digital data to analog signal C. Analog data to analog signal D. Analog data to digital signalarrow_forwardb) AND C)arrow_forwardFor the circuit shown below, identify the logic function performed by it. Also determine the high level fan-out, if Rp(pull-up resistor) = 10 ks. Compute the maximum value of Rp for a fan-out of 5. Assume that input diode has a leakage current of 100 μA. Given: V₁ = 0.7V, V (forward voltage drop) = 0.8V, VBE(cut-in) = 0.5V, VCE(sat) = 0.2V. Transistor leakage current is negligible. 1H Ao- Во Co D₂ D 20 ΚΩ P₁ P₂ 10 kQ D₁ www 10 ΚΩ >+5V Rp Іонarrow_forward
- An Intel 8085 processor is executing the program given below. MVI A, 10H MVI B, 10H BACK NOP : ADD B RLC JNC BACK HLT The number of times that the operation NOP will be executed is equal toarrow_forwardDiscuss the pin diagram of any logic gate? Explain how the NAND gate can be used to derive the other logic gates. Discuss the application of diode as positive series clipper positively biased with ideal diode, practical silicon diode. Draw the neat waveform diagrams. Elaborate the working of half wave rectifier with neat diagram and waveforms. Determine the peak output voltage and current in the 4 kW load resistor connected to the output terminals of full wave bridge rectifier, if the transformer secondary voltage is 28 Vrms. Use the practical silicon diode model. Discuss the types of transformers with their applications. Explain with a neat diagram an isolation transformer used for electrical power transmission. Also explain the transformation ratio. Explain the difference between single phase and three phase induction motors with their application in detail. Determine the back emf generated in the dc shunt motor if it takes 250 V, 41 A current while running at full load. Assume…arrow_forwardIn a simple, three-phase voltage-source inverter of the form shown in Fig. 8.18, the direct voltage va in the link is 550 V. The frequency of the inverter output is 200 Hz. Determine: (a) the rms value of the fundamental component of the output voltage, line to line and line to neutral, and (b) the rms value of the actual output voltage line to line and line to neutral.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Introductory Circuit Analysis (13th Edition)Electrical EngineeringISBN:9780133923605Author:Robert L. BoylestadPublisher:PEARSONDelmar's Standard Textbook Of ElectricityElectrical EngineeringISBN:9781337900348Author:Stephen L. HermanPublisher:Cengage LearningProgrammable Logic ControllersElectrical EngineeringISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
- Fundamentals of Electric CircuitsElectrical EngineeringISBN:9780078028229Author:Charles K Alexander, Matthew SadikuPublisher:McGraw-Hill EducationElectric Circuits. (11th Edition)Electrical EngineeringISBN:9780134746968Author:James W. Nilsson, Susan RiedelPublisher:PEARSONEngineering ElectromagneticsElectrical EngineeringISBN:9780078028151Author:Hayt, William H. (william Hart), Jr, BUCK, John A.Publisher:Mcgraw-hill Education,
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:PEARSON
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:9781337900348
Author:Stephen L. Herman
Publisher:Cengage Learning
Programmable Logic Controllers
Electrical Engineering
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:9780078028229
Author:Charles K Alexander, Matthew Sadiku
Publisher:McGraw-Hill Education
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:9780134746968
Author:James W. Nilsson, Susan Riedel
Publisher:PEARSON
Engineering Electromagnetics
Electrical Engineering
ISBN:9780078028151
Author:Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:Mcgraw-hill Education,