Skip to content

Demonstrate how to create a dynamic digital clock using an STM32F407 microcontroller and an LCD1602 display with I2C communication via a PCF8574 I/O expander.

Notifications You must be signed in to change notification settings

nuloperrito/STM32F407_LCD1602_Reloj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32F407 + LCD1602 Dynamic Digital Clock

This project demonstrates how to create a dynamic digital clock using an STM32F407 microcontroller and an LCD1602 display with I2C communication via a PCF8574 I/O expander.

Features

  • Real-time display of current date and time
  • I2C communication via PCF8574
  • Configurable alarm and wake-up interrupts
  • LCD backlight control based on alarm state

Hardware Setup

  • Microcontroller: STM32F407
  • Display: LCD1602 with I2C interface (PCF8574)
  • I2C Pins:
    • SDA → PB7
    • SCL → PB6

Implementation Details

  • Uses the I2C1 peripheral for communication with the LCD.
  • Time and date are configured once during initialization.
  • Note: After regenerating code with STM32CubeMX, ensure that the initialization code in rtc.c under User Code 2 is moved above the configuration of the wake-up and alarm interrupts.
  • Alarm settings include configurable mask bits to control which time components (e.g., hours or dates) should trigger the alarm.

Interrupt Behavior

  • Wake-Up Interrupt:
    • Sets an external flag updateLCD
    • The while loop in main() checks this flag to update the display with the current time
  • Alarm Interrupt:
    • Turns off the LCD display
    • Disables wake-up interrupts
    • Resets the updateLCD flag

Usage

  1. Configure peripherals in STM32CubeMX, ensuring RTC and I2C are properly set.
  2. Generate code and adjust the position of RTC initialization code as noted above.
  3. Flash the firmware to your STM32F407 board.
  4. The LCD will show the current date and time, updated dynamically via I2C.

Acknowledgments

  • STMicroelectronics for STM32 and CubeMX tools
  • Open-source LCD1602 + PCF8574 libraries for STM32

About

Demonstrate how to create a dynamic digital clock using an STM32F407 microcontroller and an LCD1602 display with I2C communication via a PCF8574 I/O expander.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published