lab 1 - oled,gpio,interrupt

7
LAB 1: OLED, GPIO and Interrupt Graphical User Interfaces (GUIs) are integrated components in many embedded systems which allow displaying graphical icons and texts. In the EVALBOT, an Organic LED (OLED) display with 96x16 pixel resolution is provided. In the first part of this lab, we will use driver functions to write texts on the display and create a new function to draw lines. Graphical displays have a driver Integrated Circuit (IC) to control pixels on the panel. The OLED display in the EVALBOT uses SSD1307 as the driver which allows microcontroller to have access to the pixels through the I 2 C interface. Graphical Display Data RAM (GDDRAM) is a buffer holding the bit pattern to be displayed on the screen. Each byte of GDDRAM is dedicated to 8 pixels on the display panel. The GDDRAM page structure of SSD1307 is as follows:

Upload: prakashshr

Post on 18-Dec-2015

213 views

Category:

Documents


0 download

DESCRIPTION

blah blah blah

TRANSCRIPT

LAB 1: OLED, GPIO and Interrupt

Graphical User Interfaces (GUIs) are integrated components in many embedded systems which allow displaying graphical icons and texts. In the EVALBOT, an Organic LED (OLED) display with 96x16 pixel resolution is provided. In the first part of this lab, we will use driver functions to write texts on the display and create a new function to draw lines.Graphical displays have a driver Integrated Circuit (IC) to control pixels on the panel. The OLED display in the EVALBOT uses SSD1307 as the driver which allows microcontroller to have access to the pixels through the I2C interface. Graphical Display Data RAM (GDDRAM) is a buffer holding the bit pattern to be displayed on the screen. Each byte of GDDRAM is dedicated to 8 pixels on the display panel. The GDDRAM page structure of SSD1307 is as follows:

StellarisWare provides a library to interface GDDRAM and allows users sending control command. This library is available in \StellarisWare\boards\ek-evalbot\drivers named .In the second part of this lab, you will get familiarized with the General Purpose Input/Outputs (GPIOs) in the Stellaris Cortex M3 microcontrollers.1 Lab Objectives Basic OLED library use Adding a new character to the default font Adding a new function to the OLED library to draw lines Checking the status of touch switches with polling Use interrupt to read from the switches

The lab will be completed in one week.2 Pre-LabGet yourself familiar with the functions in the and the structure of the font. Furthermore, create a function to draw a line (draw_line) in advance. Read chapter 8 of Stellaris LM3S9B92 datasheet to learn how to set the direction, change the output values and enable interrupts for the GPIOs. You will also need to review sensor.c and io.c in the \StellarisWare\boards\ek-evalbot\drivers to find out how to control the GPIOs.

2.1 Tool Requirements1. Software: Code Composer Studio v51. Hardware:1. The Stellaris Robotic Evaluation Board (EVALBOT)

3 Lab Procedure

Repeat all the steps you learned in Lab0 to create a new project in CCSv5. You might need to add other resources to your projects.

3.1 Displaying strings

Write a program to display Hello World! on the screen. These two functions are useful for this part:Display96x16x1Init(tBoolean bFast) Display96x16x1StringDrawLen(const char *pcStr, unsigned long ulLen, unsigned long ulX, unsigned long ulY)

Note : Add PART_LM3S9B92 into the predefined symbols.

3.2 Add a new character to the font listFind the font list in the and add a new character to the end of the list after ~. The new character should look like this:

Write a program to display Hello World []. The last character is your new character.3.3 Create a function to draw lineWrite a program to draw a line on the screen. You define the line with 2 points (x1,y1) and (x2,y2). You can find points between (x1,y1) and (x2,y2) using the following equations:

x = x1- (x1 - x2)y = y1- (y1 - y2)where0 < < 1.

Since Cortex M3 is a fixed-point processor, should be scaled. For example the last equation can be rewritten as

y = y1- ((y1-y2) / 100) where 0 < < 100, being an integer

3.4 Control LEDs with bump sensors by pollingIn this section you are not allowed to use drivers for the EVALBOT. Instead, use functions available in the driverlib. Write a program to show the status of bump switches on LEDs. i.e., turn LED1 on/off with switch4 and LED2 with switch3.1. Enable the clock for the ports connected to bump sensors and LEDs. (PORTE and PORTF)2. Set direction of LED pins output and bump switches input.3. Enable pull-up resistor for bump sensors4. In an infinite loop update LEDs according to bump-sensors

You might use these functions:ROM_SysCtlPeripheralEnableROM_GPIOPinTypeGPIOInputROM_GPIOPinTypeGPIOOutputROM_GPIOPadConfigSetROM_GPIOPinReadROM_GPIOPinWrite 3.5 Using interrupt instead of pollingIn Section 3.4, you used polling to read from switches and write onto the LEDs. Instead of wasting MPU cycles to check the pin status in an infinite loop, GPIO interrupts can be used to notify the processor when an event occurs.Write the program with similar functionality as the one in Section 3.4 but with the GPIO interrupt.1. Add to your project. In this file, all interrupt sources for LM3S9B92 are listed. You can define the function to be executed for each interrupt. For interrupts on GPIO PORTE, BumpSensorIntHandler is used.2. Configure GPIOs the same way as in the main code.3. Add void BumpSensorIntHandler(void) to your c file and update/output the LEDs in the function.4. To enable interrupts on switch pins, add these lines to your c file:GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1);GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_BOTH_EDGES);

BumpSensorIntHandler is called anytime GPIO_PIN_0 or GPIO_PIN_1 of PORTE have an activity. This could be either falling edge or rising edge on the pin.4 Lab Questions (to be answered in your report) What problems did you encounter in this Lab? What part of the ASCII table does support? What will be shown on the display if the character is out of the defined range? If you want to use (switch1 and switch2) instead of bump sensors (switch3 and switch4), how would you configure the GPIOs? What are the other events in addition to falling or rising edges that can be used to trigger GPIO interrupt?5 Lab ReportInclude the following items in your report:

Answers to Questions Create a zip file for your codes for Sections 3.1, 3.2, 3.3, 3.4 and 3.5 and email it to the TAs along with the report.

6 DocumentsThere are many useful documents you will need as references for this lab including:

Stellaris Robotic Evaluation Board (EVALBOT) User's Manual This document contains all the information about the EVALBOT you will be using, some of which will be reproduced here. Designated spmu166 and available at the following URLhttp://www.ti.com/lit/ug/spmu166/spmu166.pdf

Stellaris LM3S9B92 Microcontroller Data Sheet - This document contains hardware information about the LM3S9B92 device itself and its specifications. In this document you can also find all registers, modules and peripherals information.http://www.ti.com/lit/ds/symlink/lm3s9b92.pdf

Stellaris Peripheral Driver Library Users Guide This document describes set a set of drivers for accessing the peripherals found on the Stellaris family of ARM Cortex M based microcontrollers.http://www.ti.com/lit/ug/spmu019m/spmu019m.pdf

OLED/PLED Segment/Common Driver with Controller SSD1307 This document describes the structure of memories that control pixels on OLED.http://www.trulydisplays.com/oled/specs/IC%20SSD1307%20Spec.pdf