Close

Double Play with on-board Trellis Encoder

A project log for Digital TV signal from Parallax P2 microcontroller

Some home computers used to have RF video output. The P2 could bring that back with ATSC HDTV output.

real-solar-carsReal Solar Cars 11/10/2025 at 23:320 Comments

The trellis encoder is the part of the ATSC standard that adds the most excess data. It's also one of the last steps before transmission.  It takes in 2 bits of data and outputs 3 bits.   I opted to store the 3 bit symbols in 4 bits.  At least initially, getting it to work correctly was more important that maximizing video play time.

If the trellis encoding could be done on the P2 the video playback time would be doubled. It would also make it easier to play longer videos directly from the SD card due to the reduced data rate required. 

A Look-Up-Table can be a good way of computing complex operations quickly, provided the input space is not too large.  In the graph we can see that the trellis encoder has 3 bits of memory inside.  The table will need the current state as an input and the next state as an output. 

InputInputOutputOutput

Total% of
StateDataStateDataTable
tableOn-chip
bitsbitsbitsbitsentriesbitsbytesRAM used
3233326240.00
343612891440.03
3831220481538400.73
316324524288271769472337.50








38312204864163843.13

Processing 8 bits of data at a time results in a table of 2048 entries. Quite reasonable. 

I opted to use 64 bits per entry to save time unpacking the results. The P2 has a burst memory access mode such that additional 32 bit words add only 1 clock cycle.  Memory usage of 16kB of the 512kB is quite tolerable. 

The trellis encoder along with associated housekeeping uses about 50% of one core of the P2 microcontroller at 300MHz.

Discussions