Step 3.1: Create slcd_library folder and add related files
3
Copy the slcd library files lcd.h, lcd_basic.h, moving_string.h, sleep_wakeup.c files into the slcd_libary folder. These files are present in dev_files folder in the ZIP file you downloaded.
Go to the extracted ZIP folder of the project (we extracted the project files in step 1.1.1). In this folder, locate source files by navigating to the folder saml22_slcd/saml22_slcd_lab/dev_files/slcd_library. Copy the files present inside slcd_library and paste the files into the slcd_library folder (<your_development_project_folder>/saml22_slcd/saml22_slcd_lab/saml22_slcd_lab/src/slcd_library), created in step 3.1.1 and 3.1.2.
4
Adding SLCD library files lcd.h, lcd_basic.h, moving_string.h, sleep_wakeup.c files into the slcd_libary folder in the project.
In solution explorer, under src folder navigate to slcd_library folder and right-click on it, then select options Add and Existing item. A pop up window will appear. Navigate to
<your_development_project_folder>/saml22_slcd/saml22_slcd_lab/saml22_slcd_lab/src/slcd_library, select lcd.h, lcd_basic.h, moving_string.h, sleep_wakeup.c using
Ctrl button and click on the Add button. All files will be added into your project.
The following table explains the role of each file inside the slcd_library folder.
File name | Contents in the file |
---|---|
lcd.h | Contains SLCD function prototypes,macros. |
lcd_basic.c | Contains SLCD APIs to configure lcd, display string and to display all segments of SLCD. |
Moving_string.c | Contains APIs to scroll the string on SLCD. |
Sleep_wakeup.c | Contains API's for lcd sleep implementation and RTC configurations. |
After this step, the files under the solution explorer should look like this.
Step 3.2: Replace conf_slcd.h with conf_slcd.h provided in dev_files folder
Replace the generated conf_slcd.h file present in
saml22_slcd/saml22_slcd_lab/saml22_slcd_lab/src/config
with the conf_slcd.h file present in the extracted ZIP folder,
saml22_slcd/saml22_slcd_lab/dev_files.
This configuration file also contains following macros, used in the lab.
- CONF_LCD_CONTRAST - To change the contrast
- CONF_WAVEFORM_MODE - To change the SLCD waveform mode
- CONF_LCD_MOVING_FRAME_DELAY - To change the frame delay for a moving string
- CONF_LCD_FRAME_DELAY - To change the frame delay for blinking
- CONF_LCD_STRING - The string to be displayed in SLCD
- CONF_TEMP_DELAY - The time in milliseconds before device needs to be moved into sleep mode
- CONF_DISABLE_BLINK - Configuration value of frame delay to disable blinking
Step 3.3: Initialize the Segment LCD controller
1
This step is to Initialize and turn on all segments of LCD.
1.a
Open main.c file from the solution explorer.
1.b
Clean up the generated skeleton code (which sets the LED on and off by accessing the state of a button) inside the main function, which is not necessary for this lab.
1.c
Add header files #include "conf_slcd.h" and #include "slcd_library/lcd.h" above the main() function.
1.d
Call functions system_init() and delay_init() to Initialize system and delay modules as shown in the code below.
- system_init() : The system_init function initializes system clock, board hardware, event system driver and external Interrupt driver.
- delay_init() : This must be called during start up to initialize the delay routine with the currently used main clock. It must run any time the main CPU clock is changed.
1.e
Enable global interrupts in the device to trigger any enabled interrupt handlers by calling the function system_interrupt_enable_global() as shown in the code below.
You can copy the code snippet from the following text box.
/* Initializes system clock, board hardware */
system_init();
/* Initialize the delay driver */
delay_init();
/* Enable global system interrupt */
system_interrupt_enable_global();
while(1);
2
Configure the SLCD using the function lcd_configure() with the parameters CONF_WAVEFORM_MODE and CONF_LCD_CONTRAST as shown in the code below. Both these parameters are defined as macros in header file conf_slcd.h, CONF_WAVEFORM_MODE macro by default, set to SLCD_LOW_POWER_WAVEFORM_MODE and CONF_LCD_CONTRAST macro is set to maximum value of 15. LCD controller supports two waveform modes (standard and low power mode) with respect to bias configuration. The low power mode has a lower switching frequency than the standard mode and thus reduced power consumption comparing to standard waveform; therefore, we are using a low power waveform mode.
2.a
The function lcd_configure() configures SLCD hardware pins, enables back light, and initializes the SLCD module.
2.b
Call the function lcd_display_all_seg() as shown in the code below. This function turns all the SLCD pixels on.
You can copy code snippet from the following text box.
/* SLCD Initialization */
lcd_configure(CONF_WAVEFORM_MODE,CONF_LCD_CONTRAST);
lcd_display_all_seg();
2.c
2.d
All the segments of the LCD display should be turned ON as in below image.