1 / 12

Many students find it difficult understanding the concept of Object Oriented Programming (OOP)

Many students find it difficult understanding the concept of Object Oriented Programming (OOP) Lack of exciting labs leads to a loss of interest

Download Presentation

Many students find it difficult understanding the concept of Object Oriented Programming (OOP)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Many students find it difficult understanding the concept of Object Oriented Programming (OOP) • Lack of exciting labs leads to a loss of interest • Created with partial support from the National Science Foundation’s Division of Undergraduate Education through CCD grant DUE 97-52626 and ILI grant DUE 98-50983. • MIPPET has 4 switches, 4 LED's, a High Current Output, an A/D converter and two communication ports

  2. User Code to control MIPPET MIPPET MIPPET Class

  3. Object Class provides a high level coding structure for the user Mippet (int port); // Precondition: Mippet must be connected to parallel port at // address "port" (can be 0x378, 0x278 or 0x3BC) // Postcondition: Mippet is initialized to all items off // (status port bits 0-3 low, 4-7 high) void ReadSwitches (bool & switch0, bool & switch1, bool & switch2, bool & switch3); // Precondition: None // Postcondition: Sets the switch parameters to 0 or 1 depending on // whether the switch is pressed or not at the instant // the function call is made (0 = not pressed, // 1 = pressed) // Returns: None

  4. MIPPET connects to the parallel port of a computer • All inputs and outputs are through pins on the parallel port • To use a port, we need to know its base address and the semantics of its usage provided by the data sheet

  5. MS C/C++ provides two functions to write/read from the port: inp & outp • e.g. The parallel port has a base address of 0x378. • To read the Status Port (located at the base • address+1): • int x; • x = inp(0x379); • To set or clear a bit, need to create a mask

  6. Say we want to set Logical Output 3 high. • We know that Logical Output 3 is connected to pin 4, which is bit 2 on the status port • Since we want to modify bit 2, our mask will be 0000 0100 = 0x04 • But we cannot just write 0x04 (0000 0100) to the port as this will clear all other bits.

  7. Must read in the existing value of the data port • e.g. x = inp(0x378) • We take this value and “OR” it with our mask (0x04) • “OR”ing this mask with the value read from the status port sets bit 2 and keeps all other values unchanged. • e.g. x = 1100010 1100110 • OR 0000100 0000100 • ----------- ----------- • 1100110 1100110

  8. Talking to devices is basically a matter of reading/writing to ports • Abstraction is a wonderful thing! • * Hiding • * Device changes, client does not notice

  9. QUESTIONS?

More Related