1 / 9

4-Integrating Peripherals in Embedded Systems (cont.)

4-Integrating Peripherals in Embedded Systems (cont.). Using push buttons and switches. Push buttons SW2 to SW5 on the Dragon Board are connected to bits 3 to 0 of PortH When button is pushed, a corresponding bit of Port H is reset. What activity level? Can be enabled/disabled: SW_enable();

yamka
Download Presentation

4-Integrating Peripherals in Embedded Systems (cont.)

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. 4-Integrating Peripherals in Embedded Systems (cont.)

  2. Using push buttons and switches • Push buttons SW2 to SW5 on the Dragon Board are connected to bits 3 to 0 of PortH • When button is pushed, a corresponding bit of Port H is reset. What activity level? • Can be enabled/disabled: • SW_enable(); • Can be checked with C function calls: • SW1_dip(); //returns 8-bit reading of SW1 • SW2_down(); // true if SW2 is down • SW2_up(); //true if SW2 is up. • Use • while ((PTH & 0x01)==0) //to check if the SW5 is being pressed • { • //…SW5 still pressed • } • //SW5 released

  3. Using switches • There are also 8 DIP switches (sliders) on the Dragon board. • The rightmost 4 switches share the same bits of portH with push buttons. • These switches are intended for use as level-sensitive data inputs to a circuit. • When a switch is in the ON position (away from LCD) it provides a 0 bit on corresponding PORT H bit. • What activity level? • Use: • DDRH=0x00; //Port H inputs • leds_on(~PTH);

  4. Using Keypad • The Dragon board has a 4x4 keypad, connected to Port A. • Scanning is used to minimize interface bits. See page 29. • Use C function call key_scan(). See listing 6.1 • Use C function call get_key(). See listing 6.3 • To avoid bouncing: • keypad_enable() • getkey() • wait_keyup() • keyscan()

  5. Using LEDs • The Dragon board provides 8 red LEDs. • You can use C function calls to set/reset LEDs • led_on(int b); //Sets bit b of PORTB High, or on • led_off(int b); //Sets bit b of PORTB Low, or off • leds_on(int h); //Sets bits of all 8 leds according to hexadecimal value h

  6. Seven Segment Display • The Dragon Board has four 7-segment displays. These displays are arranged with the intent of displaying numbers of medium sizes. • Must be enabled/disabled since using same port B of LEDs: • seg7_enable(); • seg7_disable(); • Applying a high logic level to a segment causes it to light up, and applying a low logic level turns it off. • seg7_on(int s, int b); //turns on segment s on 7SEG digit b • What will be the hexadecimal digit coding (assume 0 segment is least significant)? [9 coded as 0x6F] • Use seg7dec(int i, int b); //display hexadecimal value of i on 7SEG digit b

  7. E communications bus R/W RS DB7–DB0 8 microcontroller LCD controller LCD controller • Dragon board has Sanyo DM1623 display of 2x16 characters. • See control signals in pg. 33 and table 7.1 in pg 34

  8. Using LCD • See figure 4.7(d), pp 96 • Void WriteChar (char c) { • RS=0 • /*indicate control being sent*/ • DATA_BUS=0x01;//Clear Display • /*toggle LCD Enable, with delay*/ • EnableLCD (45); • //…other controls • /*indicate data being sent */ • RS=1; • /*send data to LCD */ • DATA_BUS=c; • /*toggle LCD Enable, with delay*/ • EnableLCD (45); • }

  9. Using LCD • For Dragon12 we may use: • char * msg; • msg=“Dragon12-Plus”; • lcd_init(); //set configurations • set_lcd_addr(0x01);//for first line • type_lcd(msg); • set_lcd_addr(0x45); //for second line

More Related