Hardware Reference
In-Depth Information
Example 10.11
For the circuit shown in Figure 10.30, write a program to display the following message and
shift the information from right to left every second and enable blinking:
08:30:40 Wednesday, 72°F, humidity: 60%
Solution: We use plane P0 to shift the message once every half a second. The message in plane
P0 is used to multiplex the display in half a second and the message sent to plane P1 is used to
multiplex the display in the next half of a second. We display the space character in each matrix
display using plane P1 and display the normal characters using plane P0. A delay function is
invoked once every second to shift the message to plane P0. The program is as follows:
#include “c:\cwHCS12\include\hcs12.h”
#include “c:\cwHCS12\include\spi0util.h”
#include “c:\cwHCS12\include\delay.h”
void send2max (char x1, char x2, char x3, char x4);
void openspi0 (void);
char msgP0[41] 5 “08:30:40 Wednesday, 72°F, humidity: 60% “;
void main (void)
{
char i1, i2, i3, i4;
char j1, j2, j3, j4;
char k;
openspi0();
DDRM | 5 BIT5; // configure PM5 pin for output
send2max(0x01, 0xFF, 0x01, 0xFF);
send2max(0x02, 0xFF, 0x02, 0xFF);
send2max(0x03, 0x01, 0x03, 0x01);
send2max(0x04, 0x1D, 0x04, 0x1D); // configuration register
send2max(0x40, 0x20, 0x40, 0x20); // send space character to plane P1
send2max(0x41, 0x20, 0x41, 0x20);
send2max(0x42, 0x20, 0x42, 0x20);
send2max(0x43, 0x20, 0x43, 0x20);
k 5 0;
while (1) {
i1 5 k;
i2 5 (k 1 1)%40;
i3 5 (k 1 2)%40;
i4 5 (k 1 3)%40;
j1 5 (k 1 4)%40;
j2 5 (k 1 5)%40;
j3 5 (k 1 6)%40;
j4 5 (k 1 7)%40;
sendtomax(0x20, msgP0[i1], 0x20, msgP0[j1]);
sendtomax(0x21, msgP0[i2], 0x21, msgP0[j2]);
sendtomax(0x22, msgP0[i3], 0x22, msgP0[j3]);
sendtomax(0x23, msgP0[i4], 0x23, msgP0[j4]);
delayby100ms(10); /* wait for 1 s */
k 5 (k 1 1)%40;
}
}
Search WWH ::




Custom Search