C language programming for YL-236 LCD12864 Chinese Character Display

Source: Internet
Author: User

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 );
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.