EFM32-chip peripherals-LCD Bitband operation

Source: Internet
Author: User

The day before yesterday, when I checked the official tg stk LCD routine, I found that the program was hard to understand. Although it is known that it is to extract the Com and Segment of every 8 words or meter word to form an array, this array is called const MCU_DISPLAY EFM_Display.

Taking the MI word as an example, it defines the Com and the specific bit of the Segment for each Segment of the MI word. Because tg stk has a total of seven mi characters, it defines the CHAR_TypeDef Text [7] array. Each CHAR_TypeDef contains 14 COM definitions and 14 Segment definitions. Corresponds to 14 segments of each mi word.

The same is true for 8 words.

But how does each segment correspond? Check the LCD truth table to make this table. Once the abstraction is complete, subsequent operations will become regular. Therefore, it is easier to use functions in the future.

Here we can also operate the LCD in another way. By viewing Reference manual of TG, we can find that EFM32 is to encode the Segment on the same comport into each bit in the same register. Therefore, TG has eight registers called LCD _SEGD0L ~ As long as you know the principle clearly, what is left is how to operate these registers.

In addition, we also know that each 32-bit register can be operated through bitband. Therefore, LCD operations can be implemented in another way, namely abstract, but abstract, it is represented by bitband.

Step 1: Use bitband to represent LCD _SEGD0L ~ The values of all BITs in LCD _SEGD7L. Take LCD _SEGD0L as an example:

# Define COM0_S0 0x43140800
# Define COM0_S1 0x43140804

// Omitted
# Define COM0_S22 0x43140858
# Define COM0_S23 0x4314085C

Step 2: Abstract A Table Based on the LCD truth table. For the moment, define the rice words on TG STK in 8 words. Because there are 7 characters.

Const unsigned long LED_Segment [7] [8] = {
{COM1_S1, COM1_S2, COM5_S2, COM7_S2, COM7_S1, COM3_S1, COM4_S1, COM4_S2 },
{COM1_S3, COM1_S4, COM5_S4, COM7_S4, COM7_S3, COM3_S3, COM4_S3, COM4_S4 },
{COM1_S5, COM1_S6, COM5_S6, COM7_S6, COM7_S5, COM3_S5, COM4_S5, COM4_S6 },
{COM1_S7, COM1_S8, COM5_S8, COM7_S8, COM7_S7, COM3_S7, COM4_S7, COM4_S8 },
{COM0_S9, COM1_S10, COM5_S10, COM7_S10, COM6_S9, COM2_S9, COM3_S9, COM4_S10 },

{COM0_S11, COM1_S12, COM5_S12, COM7_S12, COM6_S11, COM2_S11, COM3_S11, COM4_S12 },
{Comipvs13, comipvs14, COM5_S14, COM7_S14, COM7_S13, COM3_S13, COM4_S13, COM4_S14 },
};

Step 3: Define an array for 8-character display or an array for Meter Display. 0 ~ 9. Blank definition.

The display array needs to be designed based on the LCD's definition of 8 or meter characters.

Const char LCD _SEGMENT [11] = {0x3f, 0x06, 0xdb, 0xcf, 0xe6, 0xed, 0xfd, 0x07, 0xff, 0xef, 0x00 };

Step 4: Write the display function.

// Num indicates that data is displayed on the 8-character LCD.
// Data indicates the displayed value, ranging from 0 ~ 9, 10 indicates Blank
Void Num_Show (unsigned char Num, unsigned char Data)
{
For (unsigned char I = 0; I <8; I ++)
{
Unsigned long * Point;
Point = (unsigned long *) LED_Segment [Num] [I]);
If (LCD _SEGMENT [Data] & (0x01 <I ))
{
* Point = 1;
}
Else
{
* Point = 0;
}
}
}

The above is a way of operating the LCD. This is just a framework.

The procedure is as follows:

Http://download.csdn.net/download/efm32/4279470

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.