Welcome to Clock2UART! This project transforms your TM4C123 microcontroller into a high-precision event logger, outputting microsecond timestamps over UART every time a clock pulse is detected on PC4. Perfect for timing, debugging, and embedded experiments! ππ¬
- π Microsecond Precision: Hardware timer maintains a 64-bit microsecond counter.
- π― Event Triggered: Each rising edge on PC4 sends the current timestamp over UART0.
- π¨ UART Output: Timestamps are sent as ASCII decimal numbers, followed by CR+LF (
\r\n) for easy logging or parsing. - π€ Minimal CPU Usage: All timing and event handling is interrupt-driven for efficiency.
- π₯οΈ LCD Display: Real-time visualization of timestamps and trigger counts on a 2004A LCD.
- π§βπ» TI TM4C123 microcontroller (e.g., EK-TM4C123GXL LaunchPad)
- β²οΈ External clock or signal source (0.01 Hz to 10Hz) connected to PC4
- π UART-to-USB adapter or onboard debugger for serial output
- π‘ Optional: 2004A LCD module with PCF8574 I2C backpack for real-time display
| Pin | Function | Notes |
|---|---|---|
| π’ PC4 | Clock input (rising edge) | Triggers timestamp output |
| π‘ PA0 | UART0 RX | Connect to serial monitor |
| π PA1 | UART0 TX | Connect to serial monitor |
| π£ PB2 | I2C0 SCL | Connect to LCD PCF8574 SCL |
| π‘ PB3 | I2C0 SDA | Connect to LCD PCF8574 SDA |
- π οΈ Build and flash the firmware to your TM4C123 board.
- π Connect your clock signal to PC4.
- π₯οΈ Open a serial terminal (115200 baud, 8N1, no flow control) on your PC.
- β±οΈ Watch the magic! Each rising edge on PC4 prints the current microsecond count on a new line.
- π₯οΈ Connect an LCD as per the hardware setup to view timestamps and trigger counts in real-time.
π‘ Tip: Use any serial terminal (e.g., PuTTY, Tera Term, minicom) to view the output.
clock2uart.cβ Main application source. All initialization, interrupt handlers, and UART output routines.startup_ccs.cβ Startup and vector table (ensure the GPIOC interrupt points toGPIOCIntHandler).clock2uart_ccs.cmdβ Linker script for Code Composer Studio.
MIT License. See the top of clock2uart.c for details.
Dung Duc Phan, August 2025
This feature adds support for displaying timestamps and trigger counts on a 2004A LCD module with a PCF8574 I2C controller. The LCD provides a real-time view of the microsecond counter and the number of rising edges detected on PC4. π
- LCD Module: 2004A with PCF8574 I2C backpack.
- Connections:
- PB2 (I2C0 SCL) -> SCL on PCF8574
- PB3 (I2C0 SDA) -> SDA on PCF8574
- Ensure the I2C address matches the default
0x27or update the code if different.
- Connect the LCD module to the TM4C123 board as described above.
- Build and flash the firmware.
- Power on the system. The LCD will initialize and display:
- The current microsecond counter value.
- The total number of rising edges detected on PC4.
Note: The LCD backlight is enabled by default. Adjust the
PCF8574_BLdefinition in the code to disable it if needed.
- The firmware now prints both the timestamp and the trigger count to the UART. π¨οΈ
- Example output:
12345678 42 12345679 43 ...
- The firmware can now receive a string via UART to reset the trigger count. π
- To reset the trigger count, send the string
resetto the board.
A Python client script (control_client.py) is included to interact with the firmware. This script allows you to:
- Read UART Output: Continuously read and display data from the board. π‘
- Send Commands: Send strings to the board, such as
resetto reset the trigger count. ποΈ
-
Install Python:
- Ensure Python 3.x is installed on your system. π
- Install the
pyseriallibrary if not already installed:pip install pyserial
-
Run the Script:
- Navigate to the
PythonClientdirectory. π - Run the script:
python control_client.py
- Navigate to the
-
Interact with the Board:
- View the UART output in real-time. π₯οΈ
- Type
resetto reset the trigger count or any other string to send it to the board. βοΈ
π‘ Tip: Update the
PORTvariable in the script to match your board's COM port.