Skip to content

Documentation

TIC – timestamps and monitoring

64-bit microsecond counter, frame duration, rollover and Linux clock correlation.

TIC – monotonic LIN timebase

LIN1 and LIN2 share one 64-bit TIC in the STM32 C firmware. TIM6 counts at 1 MHz (1 TIC = 1 µs). A native overflow interrupt extends the 16-bit timer to a 64-bit monotonic microsecond counter. It starts when the STM32 application starts, independently of Linux, I²C or MicroPython.

Commands and frame fields

import lin
now = lin.tic()      # current 64-bit TIC
frame = lin.recv(1)  # next frame or None
if frame:
    start = frame['tic_start']        # uint64; microseconds
    duration = frame['tic_duration']  # uint32; microseconds
    end = start + duration
    print(start, duration, end)

Each frame stores only 64-bit start and 32-bit duration (12 bytes of time information). It also contains id, len, data, and status. Each channel FIFO holds 15 usable frames and drops the oldest entry on overflow.

Rollover and precision

The hardware TIM6 wraps every 65.536 ms. The 64-bit extension handles this continuously and only wraps after about 584,000 years at 1 MHz. A 1 µs resolution does not imply 1 µs absolute accuracy. Sniffer/slave start time is taken on UART LIN-break detection, not at the physical first edge. Master durations include some blocking UART software time. ISR latency and oscillator accuracy must be considered.

Two-channel correlation

a = lin.recv(1)
b = lin.recv(2)
if a and b:
    print('start offset [us]:', b['tic_start'] - a['tic_start'])
    print('end offset [us]:',
          (b['tic_start']+b['tic_duration']) -
          (a['tic_start']+a['tic_duration']))

Relating TIC to Unix time

TIC is not UTC. A host may associate a clock sample with a TIC reference:

unix_time = unix_reference + (tic - tic_reference) / 1_000_000.

The host should bracket I²C reads with clock samples, estimate communication uncertainty, and resynchronize during long captures to compensate for oscillator drift. The STM32 intentionally stores monotonic timestamps, not wall-clock strings.

Validation

On a Raspberry Pi 5, 1,000 LIN requests completed with zero data errors; measured master durations ranged from 4,465 to 4,712 µs at 19,200 baud with four data bytes. These are development firmware test observations, not a metrology accuracy guarantee.

Command reference · Overview