Hardware Reference
In-Depth Information
Step 6
If (k , 6) go to step 4.
Step 7
j
j 1 1;
Step 8
If (j , 100) go to step 3.
Step 9
i
i 1 1;
Step 10
If (i , 10)
go to step 2;
else go to step 1.
The program that can display the specifi ed seven-segment pattern sequence is as follows:
#include “c:\cwHCS12\include\hcs12.h”
#include “c:\cwHCS12\include\delay.h”
void SetClk8(void);
unsigned char SegPat[16] 5 {0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x67, 0x3F,
0x06, 0x5B, 0x4F, 0x66, 0x6D};
unsigned char digit[6]
5 {0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF};
void main(void) {
int i, j, k;
SetClk8(); // set E-clock frequency to 24 MHz
DDRB 5 0xFF; //configure Port B for output
DDRP 5 0xFF; //configure Port P for output
while(1) {
for (i 5 0; i , 10; i 11 ) { // pattern array start index
for (j 5 0; j , 100; j 11 ) { // repeat loop for each pattern sequence
for (k 5 0; k < 6; k 11 ) { // select the display # to be lighted
PTB
5 SegPat[i 1 k]; // output segment pattern
PTP
5 digit[k];
// output digit select value
delayby1ms(1);
// display one digit for 1 ms
}
}
}
}
}
// include SetClk8(void) here
5.9 Miscellaneous Items
5.9.1 Automatic, External, Static, and Volatile
A variable defined inside a function is an internal variable of that function. These variables
are called automatic because they come into existence when the function is entered and disap-
pear when it is left. Internal variables are equivalent to local variables in assembly language.
External variables are defined outside of any function and are thus potentially available to
 
Search WWH ::




Custom Search