Interfacing with the Led&Key module via the TM1638 IC
- Name: Võ Nhật Trường
- Email: truong92cdv@gmail.com
- GitHub: truong92cdv
667182019075250538.mp4
- The 7-segment LED simulates a time counter in the hh-mm-ss format.
- The 8 LEDs in the top row have left and right shifting effects.
- Pressing the buttons will turn off the corresponding 7-segment LED display.
- ZUBoard 1CG model XCZU1CG-1SBVA484E
- Led&Key control module MDU1093 with integrated TM1638 IC.
- Three signal lines: STB, CLK, DIO; power lines: VCC +5V and GND.
Refer to the TM1638 Datasheet.
The TM1638 IC efficiently controls LEDs and scans keys using only three signal lines: STB, CLK, and DIO. Internally, the TM1638 has 16 8-bit registers, addressed from 00h to 0Fh.
There are three communication modes with TM1638:
- Data transmission with automatic address increment.
- Data transmission with a fixed address.
- Reading key scan data.
The required data transmission frames are as follows:
Data is written to the TM1638 via the DIO pin on the rising edge of the CLK signal, and data is read from the TM1638 on the falling edge of the CLK signal.
Schematic diagram of the Led&Key TM1638 module:
- Generates a 1 Hz (1s) clock from the 100 MHz clock of ZUBoard.
- Displays 8 digits on the 7-segment LED in hh-mm-ss format. The counter increments on each rising edge of the 1Hz clock (1s).
- The 7-segment LED in this project is of the common cathode type. The input is a 4-bit BCD digit, and the output is an 8-bit encoded signal for the LED segments DP, G, F, E, D, C, B, A.
This module creates the data transmission and reception frames for communication with TM1638. The rw flag indicates whether data is being sent or received.
The output CLK signal has a period of T(CLK) = 2^7 * 10 ns = 1.28 µs.
Waveform of tm1638_tb
The data transmission and reception process in the top module occurs as follows:
- Send command 0x42 to indicate readiness to receive key scan data.
- TM1638 sends 4 bytes of data. Decode to determine which key was pressed.
- Send command 0x40 to indicate readiness to transmit data, with automatic address increment mode.
- Send command 0xc0 to specify that the first register address is 00h.
- Send 16 bytes of data to write to the internal registers of TM1638, controlling the LEDs.
- Send command 0x8f to set the maximum display brightness.
Waveform of top_tb