EE192: Mechatronics Design Lab

Checkpoint 1 (draft 1-23-2018)

Checkoff Requirements

Introduction

This lab is designed to introduce you to the Freescale Kinetis K Freedom development board (K64F), the MCUXpresso development environment, and give you some basic practice with soldering.

Useful documentation and pinout information can be found here:

We have created a useful set of code samples to get you started with MCUXpresso. You can clone the skeleton code from github here:

Clone Me!

The code samples demonstrate various useful capabilities of FreeRTOS (threading, interrupts, gpio toggling, pwm, etc.) and will be updated periodically, as needed, throughout the semester.

The code samples that will be useful for today include the subprojects “frdm64f_blink_led” and “frdmk64_toggle_gpio”.

Let's start with “frdm64f_blink_led”. This program is setup to blink the K64f's built-in green LED at 1hz with a 50% duty cycle. Open MCUXpresso, Import the project “frdm64f_blink_led”, build, and run it to see the green LED blink at 1hz with a 50% duty cycle. Read through the code in frdm64f_blink_led/source/main.c as you will have to modify it slightly.

To checkoff for this lab you need to do 3 things:

1. Toggle a GPIO pin instead of the internal LED. This GPIO pin will then be used to drive an external LED

2. Change the duty cycle from 50% to 75%

3. Build an LED circuit

Toggling a GPIO Pin (Step 1)

First, select the GPIO pin of your choice (we used PTB23).

K64F Pinout 

You must configure the board pin multiplexer to recognize this pin. Follow the directions here:

http://www-inst.eecs.berkeley.edu/~ee192/sp18/docs/add_pin_to_board_mcux.pdf

Read through the code in “frdmk64_toggle_gpio/source/main.c” to get an idea of how to initialize and toggle an arbitrary GPIO pin (we used PTB23). Use this logic in “frdm64f_blink_led” to toggle a GPIO pin instead of the internal LED.

You can use the oscilloscope to verify the wave produced is a 1hz 50% duty cycle wave!

Changing the duty cycle from 50% to 75% (Step 2)

We want a 1hz wave with 75% duty cycle meaning the wave is periodically “on” for .75 seconds and off for .25 seconds every second.There are a couple ways to do this- be creative!

Building the LED Circuit (Step 3)

Using the perfboard handed out in discussion (1 per team) solder a basic LED circuit. Be careful with the perfboard and K64f as there is only one per team (do not solder anything onto the K64f directly, instead insert wires into the headers on the board).

LED Circuit 

You will need to build a circuit consisting of an LED and resistor.

Be sure to choose the value of the current-limiting resistor so that the LED receives about 1.6mA of current. The supply voltage is 3.3V.

Extra Information

Version Control with Git

It's good to get into the habit of working with version control. This will pay dividends in the near future. Version control will let you easily save (and if necessary, roll back to) a version of code that works. It also enables multiple team members to work on code and merge changes.

Private course GitHub repositories will be handed out during checkpoint 0. If your team has not received your private repository yet, please email the TA (remembering to include to GitHub usernames of all team members).

The starter code can be found on GitHub.

You can also download the GitHub GUI client here. This should not require administrator permissions to run on the lab machines. SmartGIT works pretty nicely as well for non-commercial purposes: SmartGit.

MCUXpresso Setup

We will be using MCUXpresso, an Eclipse based IDE for MCU development, to develop applications in C for the K64F. The lab machines already have MCUXpresso installed. If you want to work on your own personal machine you need to install and setup MCUExpresso locally.

http://www-inst.eecs.berkeley.edu/~ee192/sp18/docs/MCUXpressoDirections.pdf