example 5 pushbutton switches s1 and s2 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Example 5 Pushbutton Switches: S1 and S2 PowerPoint Presentation
Download Presentation
Example 5 Pushbutton Switches: S1 and S2

Loading in 2 Seconds...

play fullscreen
1 / 8

Example 5 Pushbutton Switches: S1 and S2 - PowerPoint PPT Presentation


  • 93 Views
  • Uploaded on

Example 5 Pushbutton Switches: S1 and S2. Lecture L3.1. 2 pushbutton switches. Serial cable. A/D Pot. Run/Load switch. Reset button. 7-segment display. Power plug. I/O headers. miniDragon+. Pushbutton Switches: S1 and S2. (PORTAD0 & 0x10) == 0. TRUE if S1 is closed.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Example 5 Pushbutton Switches: S1 and S2' - kyna


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

2 pushbutton switches

Serial cable

A/D Pot

Run/Load switch

Reset button

7-segment display

Power plug

I/O headers

miniDragon+

slide4

Pushbutton Switches: S1 and S2

(PORTAD0 & 0x10) == 0

TRUE if S1 is closed

(PORTAD0 & 0x08) == 0

TRUE if S2 is closed

slide5

Example 5a

// Example 5a: Pushbutton Switches

#include <hidef.h> /* common defines and macros */

#include <mc9s12dp256.h> /* derivative information */

#include "main_asm.h" /* interface to the assembly module */

#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"

void main(void) {

PLL_init(); // set system clock frequency to 24 MHz

seg7_enable(); // enable 7-segment display

ATD0DIEN = 0x18; // enable S1 and S2

while(1){

if((PORTAD0 & 0x10) == 0)

seg7dec(1);

else

seg7_off();

if((PORTAD0 & 0x08) == 0)

seg7dec(2);

else

seg7_off();

}

}

slide6

Example 5b

// Example 5b: Pushbutton Switches using C function calls

#include <hidef.h> /* common defines and macros */

#include <mc9s12dp256.h> /* derivative information */

#include "main_asm.h" /* interface to the assembly module */

#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"

void main(void) {

PLL_init(); // set system clock frequency to 24 MHz

seg7_enable(); // enable 7-segment display

SW12_enable(); // enable S1 and S2

while(1){

if(SW1_down())

seg7dec(1);

else

seg7_off();

if(SW2_down())

seg7dec(2);

else

seg7_off();

}

}

slide8

Example 5c

// Example 5c: Pushbutton Switches - Problem 5.3

#include <hidef.h> /* common defines and macros */

#include <mc9s12dp256.h> /* derivative information */

#include "main_asm.h" /* interface to the assembly module */

#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"

void main(void) {

PLL_init(); // set system clock frequency to 24 MHz

seg7_enable(); // enable 7-segment display

SW12_enable(); // enable S1 and S2

while(1){

while(SW1_down()){

seg7dec(1);

}

seg7_off();

while(SW2_down()){

seg7dec(2);

}

seg7_off();

}

}