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

1 / 8
About This Presentation
Title:

Example 5 Pushbutton Switches: S1 and S2

Description:

Title: Introducing the 68HC12 Author: Richard Haskell Last modified by: haskell Created Date: 4/17/1999 9:03:43 PM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 9
Provided by: RichardH210
Category:

less

Transcript and Presenter's Notes

Title: Example 5 Pushbutton Switches: S1 and S2


1
Example 5Pushbutton Switches S1 and S2
  • Lecture L3.1

2
miniDragon
3
(No Transcript)
4
Pushbutton Switches S1 and S2
(PORTAD0 0x10) 0
TRUE if S1 is closed
(PORTAD0 0x08) 0
TRUE if S2 is closed
5
Example 5a
// Example 5a Pushbutton Switches include
lthidef.hgt / common defines and macros
/ include ltmc9s12dp256.hgt / 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()

6
Example 5b
// Example 5b Pushbutton Switches using C
function calls include lthidef.hgt / common
defines and macros / include ltmc9s12dp256.hgt
/ 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()
7
Example 5
8
Example 5c
// Example 5c Pushbutton Switches - Problem
5.3 include lthidef.hgt / common defines and
macros / include ltmc9s12dp256.hgt /
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()
Write a Comment
User Comments (0)
About PowerShow.com