Interface LCD with SAM L22 MCU Tutorial: Step 4

Step 4.1: Implement ASCII character mapping and software contrast control

1

This step displays the string “MCHIP” on the SLCD display.

1.a

Open main.c file from the Solution Explorer.

1.b

In the main() function, comment call to function lcd_display_all_seg().

1.c

Call function lcd_display_string() with parameters as shown in the code snippet below. CONF_LCD_STRING macro default value is "MCHIP" and CONF_DISABLE_BLINK macro is set to zero, which disables blinking.

code_snippet2.PNG

You can copy the code snippet from below text box.

/* ASCII Character Mapping */
lcd_display_string(CONF_LCD_STRING, CONF_DISABLE_BLINK);

1.d

Build build.png and program run.png the code.

1.e

"MCHIP" should be seen as shown below.

result2.png

2

This step changes the contrast of Segment LCD.

The contrast of the LCD is determined by the value of VLCD voltage. The higher the VLCD voltage, the higher is the contrast and the software contrast adjustment is only possible in internal supply mode. In internal supply mode, VLCD is in the range of 2.5 V to 3.5 V. The contrast value can be written at any time, even if SLCD is enabled and running.

The contrast values can be modified by changing the value of macro CONF_LCD_CONTRAST.This can be changed between values of 0-15 with increasing order of brightness.

2.a

Open the conf_slcd.h file from saml22_slcd/saml22_slcd_lab/saml22_slcd_lab/src/config.

2.b

Change the value of macro CONF_LCD_CONTRAST to 3 and view the change in contrast value reflected on SLCD screen after building build.png the project and programming run.png code on the device.
result22.png

2.c

Similarlly change the value of macro CONF_LCD_CONTRAST to 15 and view the change in contrast value reflected on SLCD screen after building build.png the project and programming run.png code on the device.
result2.png

Step 4.2: Implement hardware blinking

1

This step configures hardware blinking feature of SLCD.
SLCD can be configured to blink all or selected LCD segments. Segments will alternate between an on and off state at the frequency given by the selected frame counter.

1.a

Open main.c file from the Solution Explorer window.

1.b

Modify the function lcd_display_string() in the main() function to enable blinking, from
lcd_display_string(CONF_LCD_STRING, CONF_DISABLE_BLINK)
to lcd_display_string(CONF_LCD_STRING,CONF_LCD_FRAME_DELAY), where macro
CONF_LCD_FRAME_DELAY is the frame delay used while blinking (0-7). This can be modified in conf_slcd.h. Modifying the value of macro CONF_LCD_FRAME_DELAY to higher value will decrease blink rate.

1.c

Frame rate can be calculated by formula Frame Rate = FCLK_SLCD_OSC/(PVAL * (CKDIV + 1) * NbCOM), where:
FCLK_SLCD_OSC = 32 KHz = 32768 Hz (SLCD Clock)
PVAL = 32 (Prescale value of clock)
CKDIV = 7 (LCD clock divider)
NbCOM = 4 (Number of COM lines used)
The above values are populated from the configuration file of SLCD module by substituting the values mentioned in conf_slcd.h in the above frame rate formulae.
Frame Rate = 32768 / ((32 x (7 + 1) x (4)) = 32.

1.d

The frame counter is set using the configuration macro, CONF_LCD_FRAME_DELAY value, which is set to the frame counter register FCX.OVF. The frequency of the internal event of update/blinking is defined using the below formulae.

formulae.png

Setting CONF_LCD_FRAME_DELAY to 1, the frequency of update in the SLCD screen will be 32/((1x8)+1) = 3.55 Hz.

code_snippet3.png

You can copy code snippet from the text box below.

/* Hardware Blinking Feature */
lcd_display_string(CONF_LCD_STRING, CONF_LCD_FRAME_DELAY);

1.e

Build build.png and program run.png the code.

1.f

You can observe that the display blinks at 1 second rate.

result3.png

Step 4.3: Implement waking up from standby sleep mode and lower power consumption

This step configures the SLCD to operate in sleep mode and demonstrate power consumption of system in sleep and active mode. You are going to measure the power consumption using Data Visualizer for MCU only and differentiate the power saved by SLCD while operating between sleep and active modes.

1

In this step, you will display string, SLEEP, at fixed intervals and move to sleep when inactive.

1.a

Open the main.c file from the Solution Explorer and navigate to the main() function.

1.b

Comment calls to all other features of SLCD as shown in the code snippet below.

1.c

Call function lcd_configure() with the parameters as shown in the code snippet below to configure SLCD in low waveform mode with default contrast value.

1.d

Configure system to operate at default system standby sleep mode configuration using the function lcd_sleep_mode_standby_conf() as shown in the code snippet below.

1.e

Display the string, SLEEP, at fixed intervals. The device will remain in standby sleep mode in between the intervals. We use the function lcd_sleep_mode_display() to achieve this functionality.

code_snippet4.png

You can copy code snippet from below text box.

/* LCD Waking Up from Standby Sleep Mode */
lcd_configure(CONF_WAVEFORM_MODE, CONF_LCD_CONTRAST);
lcd_sleep_mode_standby_conf(CONF_TEMP_DELAY, CONF_LCD_FRAME_DELAY);
lcd_sleep_mode_display();

1.f

Build build.png and program run.png the code.

1.g

String, SLEEP, should be displayed on SLCD as shown below.

result4.png

2

Use the Data Visualizer to read current consumption values. The current consumption will be low when MCU is in sleep state. The Data Visualizer can be opened from the Atmel Studio Menu (Tools > Data Visualizer).

data_visualizer.png

2.a

Click on the Connect button to have the Data Visualizer ready to receive information from the Xplained Pro Board.

dvconnect.png

2.b

After the Data Visualizer is connected to the Xplained Pro, select the 'Power' interface and click on the Start button.

dvstart.png

2.c

Note that Data Visualizer is showing that the power consumption is low (in standby mode) for most of the time for the above assignment. Now you are able to see that the power consumption differs between active mode and standby mode, highlighted in red colour with text for active mode and sleep mode in below image.

dvresult1.png

2.d

SLCD lower power consumption are dependent on SLCD's contrast configuration, waveform mode and frame delays . Using the lowest frame rate, contrast value in low power waveform mode will reduce power consumption and the current consumption between waveform modes will depend on the type of glass and size of pixel. Therefore, you may not notice a huge difference between modes with the SLCD Xplained Pro board.

Step 4.4: Implement scrolling

1

This step scrolls a string on SLCD.

1.a

Open the main.c file from the Solution Explorer and navigate to the main() function.

1.b

Comment calls to all other features of SLCD as shown in the code snippet below.

1.c

Configure the DMA for peripheral trigger for a source memory to the LCD peripheral transfer using the configure_dma_moving_str() function with the parameters as shown in the code snippet below.

1.d

Call function lcd_configure() as shown in the code snippet below to configure SLCD in low waveform mode with default contrast value.

1.e

Call function lcd_display_moving_string() with parameter CONF_LCD_MOVING_FRAME_DELAY, which enables the scrolling feature of SLCD.

code_snippet5.png

You can copy the code snippet from the text box below.

/* Scrolling on LCD */
configure_dma_moving_str();
lcd_configure(CONF_WAVEFORM_MODE, CONF_LCD_CONTRAST);
lcd_display_moving_string(CONF_LCD_MOVING_FRAME_DELAY);

1.f

Build build.png and program run.png the code.

1.g

You are able to configure LCD for scrolling and view a string, MICROCHIP, scrolled on the LCD display.

result5.png

 Results

You have configured and observed the output of different features of the SAM L22 SLCD controller using SAM L22 Xplained Pro Evaluation Kit and Segment LCD1 Xplained Pro extension board.

 Analysis

In this lab, you have successfully configured features of the SLCD controller on the SAM L22 microcontroller and observed the output on Segment LCD1 Xplained Pro board mounted on SAM L22 Xplained Pro Evaluation Kit. Data Visualizer was used to measure the power consumption. As part of this lab, you got hands-on experience creating a project using Atmel Studio, adding drivers with help of ASF Wizard, including library files to the project, and programming the device. You also learned how to configure the Data Visualizer to measure the power consumption.

 Conclusions

In this tutorial, you have discovered the main features of the Segment LCD Controller (SLCD) and how to configure and use them to make the application power-efficient. If you need to add a segmented LCD display to any of your existing applications, this tutorial can be used as a reference. LCD displays can be used in battery operated and low power products where you need a monochrome display with few lines and low power consumption.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.