microsystems on silicon

DOCI Interface

The DOCI™ interface is a single wire interface between a MOS device and any micro controller. DOCI™ is an acronym for Data Out Clock In.

Serial data transfer between the device and the micro-controller is done exclusively on the DOCI pin. The DOCI pin combines functions of a clock input as well as a current limited output driver. The MOS device indicates a successful sample by pulling the DOCI pin to VDD. To read a data bit, the micro-controller generates a zero to one transition and releases DOCI line. Depending on the data bit value, the MOS device will keep the DOCI pin high or pull it low through its output driver. The settling time depends on the total capacitive load on the DOCI pin, typically 1µ. The micro-controller samples the value and generates (drives) a new zero to one transition. This process is repeated until all the data bits is clocked out. The first bit read is the most significant bit. After the last bit has been read, the micro-controller must set DOCI to zero and release it to enable the MOS device to flag that the next sample is ready to be clocked out.

When a new sample-ready is indicated, by the MOS device, the micro-controller has to wait for at least 1 internal clock cycle of the device’s oscillator (1/FCLK, before the read procedure is started.

If the reading process is interrupted for longer than tREP and DOCI is at zero, the serial data register will be updated with a new sample.

The DOCI pin can be used as an interrupt to the micro-controller indicating that data is ready to be clocked out of the device.

doci schematic image

Sample source code

The C function below reads the register value (15bits) from the M2012A with a PIC micro controller.

//========================================================== // Read filter from M2012A // DOCI is a IO pin // DOCI_BID is a bit pattern that sets or clears the direction // of the IO pad on the processor //========================================================== unsigned int dpir_filt_rd(void) { unsigned char n; // Wait for at least 1 device // clock on the sensor before loading NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); pir_data=0; for(n=0;n<15;n++) // There are 15 data bits from sensors { DOCI=0; // Clear DOCI pin TRISB&=~DOCI_BID; // DOCI pin output NOP(); // Wait a bit DOCI=1 ; // Set DOCI pin TRISB|=DOCI_BID; // DOCI Pin input pir_data<<=1; // make room for first bit NOP(); NOP(); // Wait before sampling the DOCI pin if(DOCI) // Test DOCI pin pir_data++; // Set LSB } return pir_data; // pir_data holds sensor info }

The register value must be filtered with a high pass filter to extract proper movement data from the register value. Below is a sample of a 1st order high pass filter. The factor(k) needs to be adjusted the correct time constant.

unsigned int hp(unsigned int val) { static unsigned int sum; // The sum stay in the function unsigned int hp; // Result int k =512; // Damping factor hp := val - sum/k; sum+= hp; return hp; }

// JavaScript Document