Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code below prints the number 430 on on the rightmost three digits of the display. The only part missing from the code is the

The code below prints the number 430 on on the rightmost three digits of the display. The only part missing from the code is the initialization of the LCD Num array. Complete the code and run it.

lcdADKOM FH-1138P LCD

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Note that all the memory variables LCDM8, LCDM15, LCDM19, etc have the same layout. Once the array LCD Num is initialized, it can be used with all the six alphanumeric digits. unsigned char LCD_ Num [ 10]-0xFC, 0x60, 0xDB, ...; The code below prints the number 430 on on the rightmost three digits of the display. The only part missing from the code is the initialization of the LCD Num array. Complete the code and run it // Sample code that prints 430 on the LCD monitor #include define redLED BITO #de fine greenLED BIT7 void Initialize_ LCDO; // Red at P1.0 // Green at P9.7 // The array has the shapes of the digits (0 to 9) I Complete this array.. 39 const unsigned char LCD_Num [10] -10xFC, 0x60, 0xDB, ...; // Initialize LCD segments 0-21; 26 43 LCDCPCTLO-0xFFFF LCDCPCTL2 0x0FFF ; /7Configure LEXT 32kHz crystal //Unlock CS registers // Enable LFXT do t // Clear LFXT fault flag SFRIFG1 &OFIFG while (SERIFG1&OFIFG)// Test oscillator fault flag // Lock CS registers Initialize LCD C 7ACLK, Divider1, Pre-divider16 4-pin MUX LCDCCTLO-LCDDIV1 LCDPRE 16 LCD4MUX LCDLP VLCD generated internally /1V2-V4 generated internally, v5 to ground // Set VLCD voltage to 2.60v /7 Enable charge pump and select internal reference for it LCDCCPCTL-LCDCPCLKSYNC /7 Clock synchronization enabled LCDCMEMCTL LCDCLRM // Clear LCD memory //Turn LCD on LCDCCTLO - LCDON; return P24 S43 P2.6 S41 P10.2 S39 P5.1 S37 P5.3 S35 S33 P6.7 S31 S29 P2.5S42 LCDM22 LCDM21 LCDM20 LCDM19 LCDM18 LCDM17 LCDM16 LCDM15 LCDM14 LCDM13 LCDM12 LCDM11 LCDM10 LCDM9 LCDM8 LCDM7 LCDM6 LCDM5 LCDM4 LCDM3 LCDM2 LCDM1 P2.7 S40 44H P5.2S36 P3.0 S34 P3.2 S32 A4AA4BA4CA4D A5H EG A5N A5DP A5C A5D S28 A5E A5G A5M BATT P3.3 P3.5 S24 P3.7 S22 P3.4 S25 P3.6 S23 P8.0 S21 P8.2 P7.0 P7.2 P7.4 P5.5S11 P5.7 A1Q NEGA1N A1DP A6H A6A A2H A2AA2BA2CA2D A6Q A6E A20 | A2COL A2N | A2DP A2E A2F A2GA2M A3QANTA3N A3DP RX A6B A6C A6D P7.3 ASG A6M P5.4 S12 P5.6S10 S8 S6 S9 S7 S5 S3 P10.0 TMRHRT REC SO Figure 5.2: Segment mapping (LaunchPad User's Guide (slau627a) p. 13) Accordingly, we can see that the segments A, B, C, D, E, F, G, M constitute the outer ring and the middle horizontal bars. These eight segments can be used to display the digits 0 to 9. Let's find the mapping of these segments to the memory variables LCDMx. The six alphanumeric characters on the display are numbered 1 to 6, where 6 is the right most character. Let's look up the rightmost character in Figure 5.2. We can see that the variable LCDM8 corresponds to the segments A6A, A6B, A6C, A6D, A6E, A6F, A6G, A6M. Accord ingly, LCDM8 is used to display a digit on the rightmost character Similarly, we can display digits on the second and third characters from the right, characters 5 and 4, using the variables LCDM15 and LCDM19, respectively To facilitate displaying digits (0 to 9) on the alphanumeric characters, it's a good idea to declare an array that stores the shapes of the digits. To display a digit, we look up its shape fronm the array and write it to the LCDMx variable. The declaration of the array, called LCD_Num, is shown below 38 21 REC TXIRX ,, DE 20 Figure 5.3: ADKOM FH-1138P LCD Monitor (leftmost character shows segment names) Looking at Figure 5.3, we see that the shape of zero corresponds to the segments A, B.C D, E, F. Looking at the format of LCDM8 in Figure 5.2, we can see that all the segments should be turned on except the rightmost two. This corresponds to a binary value of 11 1100, which is 0xFC. Hence, the array LCD_Num, stores the shape of zero (OxFC) at index zero. Similarly, to display 1 on the character, the segments B and C should be on. This corresponds to a binary value of 0110 0000, which is 0x60. Therefore, we'll store the shape of1 (Ox60) at index 1 Complete the array by storing the shape of 2 at index 2, etc for all the digits 0 to 9 Note that all the memory variables LCDM8, LCDM15, LCDM19, etc have the same layout. Once the array LCD Num is initialized, it can be used with all the six alphanumeric digits Note that all the memory variables LCDM8, LCDM15, LCDM19, etc have the same layout. Once the array LCD Num is initialized, it can be used with all the six alphanumeric digits. unsigned char LCD_ Num [ 10]-0xFC, 0x60, 0xDB, ...; The code below prints the number 430 on on the rightmost three digits of the display. The only part missing from the code is the initialization of the LCD Num array. Complete the code and run it // Sample code that prints 430 on the LCD monitor #include define redLED BITO #de fine greenLED BIT7 void Initialize_ LCDO; // Red at P1.0 // Green at P9.7 // The array has the shapes of the digits (0 to 9) I Complete this array.. 39 const unsigned char LCD_Num [10] -10xFC, 0x60, 0xDB, ...; // Initialize LCD segments 0-21; 26 43 LCDCPCTLO-0xFFFF LCDCPCTL2 0x0FFF ; /7Configure LEXT 32kHz crystal //Unlock CS registers // Enable LFXT do t // Clear LFXT fault flag SFRIFG1 &OFIFG while (SERIFG1&OFIFG)// Test oscillator fault flag // Lock CS registers Initialize LCD C 7ACLK, Divider1, Pre-divider16 4-pin MUX LCDCCTLO-LCDDIV1 LCDPRE 16 LCD4MUX LCDLP VLCD generated internally /1V2-V4 generated internally, v5 to ground // Set VLCD voltage to 2.60v /7 Enable charge pump and select internal reference for it LCDCCPCTL-LCDCPCLKSYNC /7 Clock synchronization enabled LCDCMEMCTL LCDCLRM // Clear LCD memory //Turn LCD on LCDCCTLO - LCDON; return P24 S43 P2.6 S41 P10.2 S39 P5.1 S37 P5.3 S35 S33 P6.7 S31 S29 P2.5S42 LCDM22 LCDM21 LCDM20 LCDM19 LCDM18 LCDM17 LCDM16 LCDM15 LCDM14 LCDM13 LCDM12 LCDM11 LCDM10 LCDM9 LCDM8 LCDM7 LCDM6 LCDM5 LCDM4 LCDM3 LCDM2 LCDM1 P2.7 S40 44H P5.2S36 P3.0 S34 P3.2 S32 A4AA4BA4CA4D A5H EG A5N A5DP A5C A5D S28 A5E A5G A5M BATT P3.3 P3.5 S24 P3.7 S22 P3.4 S25 P3.6 S23 P8.0 S21 P8.2 P7.0 P7.2 P7.4 P5.5S11 P5.7 A1Q NEGA1N A1DP A6H A6A A2H A2AA2BA2CA2D A6Q A6E A20 | A2COL A2N | A2DP A2E A2F A2GA2M A3QANTA3N A3DP RX A6B A6C A6D P7.3 ASG A6M P5.4 S12 P5.6S10 S8 S6 S9 S7 S5 S3 P10.0 TMRHRT REC SO Figure 5.2: Segment mapping (LaunchPad User's Guide (slau627a) p. 13) Accordingly, we can see that the segments A, B, C, D, E, F, G, M constitute the outer ring and the middle horizontal bars. These eight segments can be used to display the digits 0 to 9. Let's find the mapping of these segments to the memory variables LCDMx. The six alphanumeric characters on the display are numbered 1 to 6, where 6 is the right most character. Let's look up the rightmost character in Figure 5.2. We can see that the variable LCDM8 corresponds to the segments A6A, A6B, A6C, A6D, A6E, A6F, A6G, A6M. Accord ingly, LCDM8 is used to display a digit on the rightmost character Similarly, we can display digits on the second and third characters from the right, characters 5 and 4, using the variables LCDM15 and LCDM19, respectively To facilitate displaying digits (0 to 9) on the alphanumeric characters, it's a good idea to declare an array that stores the shapes of the digits. To display a digit, we look up its shape fronm the array and write it to the LCDMx variable. The declaration of the array, called LCD_Num, is shown below 38 21 REC TXIRX ,, DE 20 Figure 5.3: ADKOM FH-1138P LCD Monitor (leftmost character shows segment names) Looking at Figure 5.3, we see that the shape of zero corresponds to the segments A, B.C D, E, F. Looking at the format of LCDM8 in Figure 5.2, we can see that all the segments should be turned on except the rightmost two. This corresponds to a binary value of 11 1100, which is 0xFC. Hence, the array LCD_Num, stores the shape of zero (OxFC) at index zero. Similarly, to display 1 on the character, the segments B and C should be on. This corresponds to a binary value of 0110 0000, which is 0x60. Therefore, we'll store the shape of1 (Ox60) at index 1 Complete the array by storing the shape of 2 at index 2, etc for all the digits 0 to 9 Note that all the memory variables LCDM8, LCDM15, LCDM19, etc have the same layout. Once the array LCD Num is initialized, it can be used with all the six alphanumeric digits

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions