Close

Optical output good

A project log for DRM-114

DEFCON 27 SAO project

nick-sayerNick Sayer 08/27/2018 at 00:430 Comments

I had envisioned using the IRCOM module of the XMega32E5, but it seems that that's designed for IRDA, which is much higher speed than the 36 kHz IR detector module I've sourced for the decode side.

But all is not lost - the XMega also allows you to use the XCL system as a codec for the serial port.

The goal is for the LED to be off when the serial output is mark (high) and for the LED to be modulated with a 36 kHz square wave when the serial output is space (low). So the magic for that is to configure the port D USART to invoke the XCL module on the TX side (the IR receiver will output proper TTL serial given this configuration of the transmitter).

The XCL module will apparently only actually do anything when the USART is actively transmitting something. So in order for the idle output to wind up being low, we have to invert the pin. Having done that the goal now is for the output to be high on mark and modulated on space.

The XCL module has an LUT (look-up table) and a timer we can configure to be a PWM source. The LUT has two inputs and one output and you program it with whatever truth table you want. The two inputs are the output from the USART and the PWM output of the timer. The output goes back to the USART to be the actual output. So the behavior we want is for the output to be 1 whenever the serial port's input is 1, and to echo the timer's PWM signal whenever the serial port is 0.

As for the timer, we set it to free-run with a divide-by-8 input from the system clock, and we set up a period of 111 and for a 50% duty cycle with a compare value of half that. 32 MHz divided by 8 and again by 111 is just slightly higher than 36 kHz.

So at this point, really what's left is the UI.

Discussions