Sfr P0 = 0x80;
Sfr P1 = 0x90;
Sfr P2 = 0xa0;
Sfr P3 = 0xb0;
Sbit cs1 = P2 ^ 0;
Sbit cs2 = P2 ^ 1;
Sbit e = P2 ^ 2;
Sbit rw = P2 ^ 3; // can be directly grounded
Sbit di = P2 ^ 4;
Sbit rst = P2 ^ 5; // The default value is 1. You can directly connect to the power supply.
Extern unsigned char code abc [];
Ys (int MS)
{
Int k, d;
For (k = 0; k For (d = 0; d <123; d ++ );
}
Write (bit s, unsigned char d)
{
Rw = 0; // write allowed
Di = s; // 0 = command, 1 = Data
P0 = d; // data
E = 1; // valid. Can the falling edge and rising edge be used?
E = 0; // invalid
Rw = 1; // write prohibited
}
Writexy (unsigned char x, unsigned char y, unsigned char d)
{
Cs1 = (y/64) % 2; // cs1 = y/64, // left half = 0
Cs2 = ~ Cs1; // right half = 0
Write (0, 0x3f); // open the display
Write (0, 0xc0); // start address
Write (0, 0xb8 + x); // x address
Write (0, 0x40 + (y % 64); // y address
Write (1, d); // write data. The data height is lower.
}
Hzk16 (unsigned char x, unsigned int y, unsigned int d)
{
Unsigned int k;
For (k = 0; k <16; k ++)
{
Writexy (x * 2 + 0, y * 16 + k, abc [d * 32 + k]); // upper half Chinese Character
Writexy (x * 2 + 1, y * 16 + k, abc [d * 32 + k + 16]); // lower half Chinese Character
}
}
Main ()
{
Unsigned int k, d;
While (1)
For (k = 0; k <4; k ++) // row
For (d = 0; d <8; d ++) // Column
{
Hzk16 (k, d, d );
}
}