Skip to content

3. Examples

niwciu edited this page Aug 7, 2024 · 6 revisions

1. Basic Mode STM32G071RB - bare metal implementation

Requirements for compiling and running the example:

  1. Git installed
  2. CMake installed
  3. Make or Ninja installed
  4. ARM GNU Toolchain (gcc-arm-none-eabi) installed
  5. STM32_Programmer_CLI installed
  6. ST-link (placed on Nucleo Board) installed

Hardware requirements, configuration, and connections

  1. STM32G071 Nucleo-64


  2. LCD Keypad Shield for Arduino


  3. Pin connection between LCD Keypad Shield and Nucleo board


LCD_HD44780 library configuration - lcd_hd44780_config.h

  /************************************  LCD HARDWARE SETTINGS *******************************
   *   LCD_TYPE -> Set one of the predefined types:
   *               2004 -> 4 lines 20 characters per line
   *               1604 -> 4 lines 16 characters per line
   *               1602 -> 2 lines 16 characters per line
   *   USE_RW_PIN -> Defines HW connection between LCD and uC
   *               ON - when the RW pin is connected
   *               OFF - when the RW pin is not connected
   *  LCD_BCKL_PIN_EN_STATE -> Defines Active state of the LCD backlight enable pin
   *               HIGH - when pin active state is high
   *               LOW - when pin active state is low
   *  LCD_BUFFERING -> Define whether buffering functionalities of the LCD should be added to compilation
   *               ON - add buffering functionality to the compilation
   *               OFF - remove buffering functionality form the compilation
   ********************************************************************************************/
  #define LCD_TYPE        1602
  #define USE_RW_PIN      OFF 

  #define LCD_BCKL_PIN_EN_STATE HIGH

  #define LCD_BUFFERING  ON
  /********************************  LCD LIBRARY COMPILATION SETTINGS ************************
   *      Setting USE_(procedure name) to:
   *          ON  - add specific procedure to compilation
   *          OFF - exclude specific procedure from compilation
  ********************************************************************************************/
  #define USE_DEF_CHAR_FUNCTION           ON
  #define USE_LCD_INT                     ON
  #define USE_LCD_HEX                     ON
  #define USE_LCD_BIN                     ON

  #define USE_LCD_CURSOR_HOME             ON
  #define USE_LCD_CURSOR_ON               ON
  #define USE_LCD_CURSOR_OFF              ON
  #define USE_LCD_BLINKING_CURSOR_ON      ON

  #if LCD_BUFFERING == ON
  #define USE_LCD_BUF_INT                 ON
  #define USE_LCD_BUF_HEX                 ON
  #define USE_LCD_BUF_BIN                 ON
  #endif

How to build and run the example

  1. Open the terminal and navigate to the location where you want to clone the repository.
  2. Clone the repository to your preferred location
    git clone https://github.com/niwciu/LCD_HD44780.git
  3. Enter to LCD_HD44780/examples/STM32G071RB_NUCLEO_BARE_METAL
    cd ./LCD_HD44780/examples/STM32G071RB_NUCLEO_BARE_METAL
  4. For Make type:
    cmake -S ./ -B Debug -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug
    cd Debug
    make all
    make flash
  5. For Ninja type:
    cmake -S ./ -B Debug -G"Ninja" -DCMAKE_BUILD_TYPE=Debug
    cd Debug
    ninja
    ninja flash
  6. In some cases, the Nucleo board may require unplugging and replugging the USB port to run the program.

2. Basic Mode STM32G474 - STMCubeIDE project generated with LL drivers

Requirements for compiling and running the example

  1. Git installed
  2. CMake installed
  3. Make or Ninja installed
  4. ARM GNU Toolchain (gcc-arm-none-eabi) installed
  5. STM32_Programmer_CLI installed
  6. ST-link (placed on Nucleo Board) installed

Hardware configuration and connections

  1. STM32G474 Nucleo-64


  2. LCD Keypad Shield for Arduino


  3. Pin connection between LCD Keypad Shield and Nucleo board


LCD_HD44780 library configuration - lcd_hd44780_config.h

  /************************************  LCD HARDWARE SETTINGS *******************************
   *   LCD_TYPE -> Set one of the predefined types:
   *               2004 -> 4 lines 20 characters per line
   *               1604 -> 4 lines 16 characters per line
   *               1602 -> 2 lines 16 characters per line
   *   USE_RW_PIN -> Defines HW connection between LCD and uC
   *               ON - when the RW pin is connected
   *               OFF - when the RW pin is not connected
   *  LCD_BCKL_PIN_EN_STATE -> Defines Active state of the LCD backlight enable pin
   *               HIGH - when pin active state is high
   *               LOW - when pin active state is low
   *  LCD_BUFFERING -> Define whether buffering functionalities of the LCD should be added to compilation
   *               ON - add buffering functionality to the compilation
   *               OFF - remove buffering functionality form the compilation
   ********************************************************************************************/
  #define LCD_TYPE        1602
  #define USE_RW_PIN      OFF 

  #define LCD_BCKL_PIN_EN_STATE HIGH

  #define LCD_BUFFERING  ON
  /********************************  LCD LIBRARY COMPILATION SETTINGS ************************
   *      Setting USE_(procedure name) to:
   *          ON  - add specific procedure to compilation
   *          OFF - exclude specific procedure from compilation
  ********************************************************************************************/
  #define USE_DEF_CHAR_FUNCTION           ON
  #define USE_LCD_INT                     ON
  #define USE_LCD_HEX                     ON
  #define USE_LCD_BIN                     ON

  #define USE_LCD_CURSOR_HOME             ON
  #define USE_LCD_CURSOR_ON               ON
  #define USE_LCD_CURSOR_OFF              ON
  #define USE_LCD_BLINKING_CURSOR_ON      ON

  #if LCD_BUFFERING == ON
  #define USE_LCD_BUF_INT                 ON
  #define USE_LCD_BUF_HEX                 ON
  #define USE_LCD_BUF_BIN                 ON
  #endif

How to build and run the example

  1. Open the terminal and navigate to the location where you want to clone the repository.
  2. Clone the repository to your preferred location
    git clone https://github.com/niwciu/LCD_HD44780.git
  3. Enter to LCD_HD44780/examples/STM32G474RE_NUCLEO_CUBE_IDE_LL/
    cd ./LCD_HD44780/examples/STM32G474RE_NUCLEO_CUBE_IDE_LL
  4. For Make type:
    cmake -S ./ -B Debug -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug
    cd Debug
    make all
    make flash
  5. For Ninja type:
    cmake -S ./ -B Debug -G"Ninja" -DCMAKE_BUILD_TYPE=Debug
    cd Debug
    ninja
    ninja flash

3. Basic Mode AVR ATmega 328P

Requirements for compiling and running the example

  1. Git installed
  2. CMake installed
  3. Make or Ninja installed
  4. AVR 8-bit GNU Toolchain
  5. AVRdude Installed
  6. USBasp programmer installed and updated

Hardware configuration and connections

  1. Arduino UNO R3


  2. USBasp programmer


  3. LCD Keypad Shield for Arduino


  4. Pin connection between LCD Keypad Shield and Nucleo board


LCD_HD44780 library configuration - lcd_hd44780_config.h

  /************************************  LCD HARDWARE SETTINGS *******************************
   *   LCD_TYPE -> Set one of the predefined types:
   *               2004 -> 4 lines 20 characters per line
   *               1604 -> 4 lines 16 characters per line
   *               1602 -> 2 lines 16 characters per line
   *   USE_RW_PIN -> Defines HW connection between LCD and uC
   *               ON - when the RW pin is connected
   *               OFF - when the RW pin is not connected
   ********************************************************************************************/
  #define LCD_TYPE        1602
  #define USE_RW_PIN      OFF 

  #define LCD_BCKL_PIN_EN_STATE HIGH

  #define LCD_BUFFERING  ON
  /********************************  LCD LIBRARY COMPILATION SETTINGS ************************
   *      Setting USE_(procedure name) to:
   *          ON  - add specific procedure to compilation
   *          OFF - exclude specific procedure from compilation
  ********************************************************************************************/
  #define USE_DEF_CHAR_FUNCTION           ON
  #define USE_LCD_INT                     ON
  #define USE_LCD_HEX                     ON
  #define USE_LCD_BIN                     ON

  #define USE_LCD_CURSOR_HOME             ON
  #define USE_LCD_CURSOR_ON               ON
  #define USE_LCD_CURSOR_OFF              ON
  #define USE_LCD_BLINKING_CURSOR_ON      ON

  #if LCD_BUFFERING == ON
  #define USE_LCD_BUF_INT                 ON
  #define USE_LCD_BUF_HEX                 ON
  #define USE_LCD_BUF_BIN                 ON
  #endif

How to build and run the example

  1. Open the terminal and navigate to the location where you want to clone the repository.
  2. Clone the repository to your preferred location
    git clone https://github.com/niwciu/LCD_HD44780.git
  3. Enter to LCD_HD44780/examples/ATMEGA328P_ARDUINO_UNO_R3 folder
    cd ./LCD_HD44780/examples/ATMEGA328P_ARDUINO_UNO_R3
  4. For Make type:
    cmake -S ./ -B Build -G"Unix Makefiles"
    cd Build
    make all
    make write_fuses
    make flash
  5. For Ninja type:
    cmake -S ./ -B Build -G"Ninja"
    cd Build
    ninja
    ninja write_fuses
    ninja flash

4. Basic Mode ESP8266 NONOS SDK

Requirements

  1. Git installed
  2. Make installed
  3. ESP Toolchain installed according to esspresif doc
  4. Downloaded Flash Download Tool V3.8.5
  5. ESP8266 NodeMCU V3 installed

Hardware connections

  1. ESP8266 NodeMCU V3


  2. LCD Keypad Shield for Arduino


  3. Pin connection between LCD Keypad Shield and ESP8266 NoneMCU board


LCD_HD44780 library configuration - lcd_hd44780_config.h

  /************************************  LCD HARDWARE SETTINGS *******************************
   *   LCD_TYPE -> Set one of the predefined types:
   *               2004 -> 4 lines 20 characters per line
   *               1604 -> 4 lines 16 characters per line
   *               1602 -> 2 lines 16 characters per line
   *   USE_RW_PIN -> Defines HW connection between LCD and uC
   *               ON - when the RW pin is connected
   *               OFF - when the RW pin is not connected
   ********************************************************************************************/
  #define LCD_TYPE        1602
  #define USE_RW_PIN      OFF 

  #define LCD_BCKL_PIN_EN_STATE HIGH

  #define LCD_BUFFERING  ON
  /********************************  LCD LIBRARY COMPILATION SETTINGS ************************
   *      Setting USE_(procedure name) to:
   *          ON  - add specific procedure to compilation
   *          OFF - exclude specific procedure from compilation
  ********************************************************************************************/
  #define USE_DEF_CHAR_FUNCTION           ON
  #define USE_LCD_INT                     ON
  #define USE_LCD_HEX                     ON
  #define USE_LCD_BIN                     ON

  #define USE_LCD_CURSOR_HOME             ON
  #define USE_LCD_CURSOR_ON               ON
  #define USE_LCD_CURSOR_OFF              ON
  #define USE_LCD_BLINKING_CURSOR_ON      ON

  #if LCD_BUFFERING == ON
  #define USE_LCD_BUF_INT                 ON
  #define USE_LCD_BUF_HEX                 ON
  #define USE_LCD_BUF_BIN                 ON
  #endif

How to build and run the example

Windows

  1. Open the terminal and navigate to the location where you want to clone the repository.
  2. Clone the repository to your preferred location
git clone https://github.com/niwciu/LCD_HD44780.git
  1. Enter to LCD_HD44780/examples/ESP8266_NONOS_SDK/LCD_HD44780_TEST folder
cd ./LCD_HD44780/examples/ESP8266_NONOS_SDK/LCD_HD44780_TEST
  1. Clean the project by running clean.bat script
./clean.bat
  1. Build the project by running build.bat script
./build.bat
  1. Run flash_download_tool_3.8.5
  2. Select "Developer Mode" and "ESP8266 DownloadTool"
  3. Set all fields as it is shown on picture bellow


  4. Select COM port on which your NodeMCU board has been installed
  5. Click START to flash the IC
  6. After flash is done pres reset button on your NodeMCU board

Linux - tbd