Copy of EE128 Lab 6

.docx

School

University of California, Riverside *

*We aren’t endorsed by this school

Course

128

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

9

Uploaded by MasterLapwing1954

Report
LABORATORY #6: REPORT Serial Communication (UART, SPI, I2C) Part 1: I2C-Based 6-Axis Accelerometer and Magnetometer Part 2: SPI-Based Communication with Arduino Abstract: In this lab, we will familiarize ourselves with I2C(Inter-Integrated Circuit), a multi- master synchronous serial communication bus. In I2C, devices are classified into masters and servants and use two lines for data communication: SCL and SDA. We will use I2C to interface with an accelerometer/magnetometer sensor. In addition to this, we will familiarize ourselves with SPI based communication with Arduino. SPI, a synchronous serial protocol, classifies
devices into masters and servants and uses four wires to carry out the task of data communication: MOSI, MISO, SCK, and SS. Experiment System Specification: Part 1: 1. We will use the processor expert to communicate with the on board accelerometer and magnetometer and send the telemetry to our computer via UART to USB. 2. This experiment requires configuring the component and some additional software packages to work. 3. Send and output the accelerometer and magnetometer and message to the terminal using I2C. Part 2: 1. We will use K64F as a master and Arduino Uno as a slave device in the SPI bus. 2. SS will not be used since there is only one servant in this lab. 3. We will also use Processor Expert as well. 4. Connect the Arduino Uno and K64F via SPI line. 5. Send and output the accelerometer and magnetometer and message to the Arduino Uno’s serial monitor. Hardware Design: Part 2:
Question 1: Software Design: K64F /* ################################################################### ** Filename : main.c ** Project : Lab6_Part2 ** Processor : MK64FN1M0VLL12 ** Version : Driver 01.01 ** Compiler : GNU C Compiler ** Date/Time : 2019-11-03, 17:50, # CodeGen: 0
** Abstract : ** Main module. ** This module contains user's application code. ** Settings : ** Contents : ** No public methods ** ** ###################################################################*/ /*! ** @file main.c ** @version 01.01 ** @brief ** Main module. ** This module contains user's application code. */ /*! ** @addtogroup main_module main module documentation ** @{ */ /* MODULE main */ /* Including needed modules to compile this module/procedure */ #include "Cpu.h" #include "Events.h" #include "Pins1.h" #include "FX1.h" #include "GI2C1.h" #include "WAIT1.h" #include "CI2C1.h" #include "CsIO1.h" #include "IO1.h" #include "MCUC1.h" /* Including shared modules, which are used for whole project */ #include "PE_Types.h" #include "PE_Error.h" #include "PE_Const.h" #include "IO_Map.h" #include "PDD_Includes.h" #include "Init_Config.h" /* User includes (#include below this line is not maintained by Processor Expert) */ /*lint -save -e970 Disable MISRA rule (6.3) checking. */ /*library to configure GPIO*/ #include "MK64F12.h" unsigned char write[512]; int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { //Configure GPIO PORTB[2] SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK; /*Enable Port B Clock Gate Control*/ PORTB_GPCLR = 0x00040100; /*Configure PORTB[2] for GPIO*/ GPIOB_PDDR = 0x04; /*Configure PORTB[2] as output*/ GPIOB_PDOR = 0x00; //Initialize PORTB[2] = 0 /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ uint32_t delay; uint8_t ret, who; int8_t temp; int16_t accX, accY, accZ; int16_t magX, magY, magZ;
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