Iowa State University

CPRE 288 Laboratory


Lab 4: Digital Wall Clock & Exploring On-Chip Debugging

Lecture - Lab Connection

In lecture, you have studied the use of timers and interrupts. In this lab, you will use these hardware features to build a digital wall clock.

Prelab

  • Read through the lab description
  • Refer to the Tiva TM4C1236GH6PM Datasheet; note that Chapter 11 covers general-purpose timers. This lab uses periodic timer mode (11.3.2.1) and prescalers (Table 11-5). The default System Clock frequency for the lab platform is 16 Mhz. The register map and register descriptions are in sections 11.4 and 11.5. Keep in mind that a datasheet is NOT a textbook; you search through it to find specific detailed information. Related information is found in Sections 9.1 – 9.2 of the Textbook.
  • Read the register description section of the Tiva TM4C1236GH6PM Datasheet (Pages 727-761) (Textbook Sections 9.1-9.2). Try to understand the settings used in the clock_timer_init() function in clock_intr.c, and answer the following questions.
    • What is the System Clock frequency of our Microcontroller?
    • What prescaler is being using in clock_timer_init() for TIMER4A and TIMER4B?
    • From what value will TIMER4A need to decrement from to reach zero in 1 second, with it prescaler
    • From what value will TIMER4B need to decrement from to reach zero in 200 milliseconds, with its prescaler?
  • Print the Lab Evaluation Form.

Reference Documents

All reference documents are also available on the Resources page of the course website.

Reference Files

Download the following files to a single folder your U: drive. (Right-click and select 'Save Target As')

You'll need to put a copy or your button.h and button.c from last lab into this project.

  • clock_intr.c: The skeleton code that user timers and interrupts to implement the clock program.
  • lcd.c: A program file with a number of LCD functions
  • lcd.h: The header file for lcd.c
  • timer.c: A program file with wait functions
  • timer.h: The header file for timer.c
  • button.c: This file contains functions which you must implement if you want to read buttons.
  • button.h: The header file for button.c
  • cyBot_uart.h: Header for pre-compiled CyBot/Human UART communication
  • libcybotUART.lib: Pre-compiled Library for CyBot/Human UART communication (Note: Must change extension from .txt to .lib after copying)
  • cyBot_Scan.h: Header for pre-compiled sensor scanning
  • libcybotUART.lib: Pre-compiled Library for sensor scanning (Note: Must change extension from .txt to .lib after copying)

Notes

During this lab, you will implement either a 24-hour or 12-hour clock.

Beyond keeping time, the user must be able to adjust the time using the push buttons:

  • SW6 to increment hours
  • SW5 to decrement hours
  • SW4 to increment minutes
  • SW3 to decrement minutes
  • SW2 to increment seconds
  • SW1 to decrement seconds

The response time of the push button should be 200ms; this means that if the user holds SW2 down for a long period of time, they should see the clock's seconds continually increment higher 5 times every second.

With such a flexible user interface to adjust the time, there should be no coupling between adjusting hours and minutes or minutes and seconds. For example, when seconds are adjusted by the user and the value passes 59 when incrementing or 00 when decrementing, the value of minutes should not be adjusted.

The actual clock should function like a standard clock. I.E., if the currently displayed time is 04:59:59, the next second should display a time of 05:00:00.


Lab 4 Description

  • Lab 4 Manual: A detailed description of the objectives to complete for Lab 4

Cautions

Turn the power to the cyBOT platform off before charging. The Launchpad board consumes power and the battery will not charge if the robot is in full_mode (which it enters after calling oi_init, turning the power LED yellow). You will have to turn off open interface. The robot is charging when the robot's power LED is pulsing red and both green LEDS on the dock are lit.

Reference Files

Files Description
Tiva TM4C1236GH6PM Datasheet Information about the Tiva TM4C1236GH6PM Processor
Documentation on printf Documentation for the lcd_printf and printf function.
Lab Evaluation Form Evaluation form for Lab
Online Feedback Form Tell us what you think of the lab (feedback forms)