I'd like to interface with an older piece of computer hardware that is comunicating via a serial protocol with a bit width of .2us. Is either the Teensy 2 or Teensy 3 capable of this?
Here is a sample of the type of signal I'd like to emulate/produce (the bottom row, not the clock on top).
Here is my attempt on a Teensy 2.0
Here is the code:
As you can see from the screen capture the timing isn't very accurate.
It should be: .6us hi, .6us lo, .4us hi, .8us lo, .2us hi, 2.4us lo, .2us hi, 1.4us lo, .2us hi, .6us lo, .6us hi
instead, I'm getting: .76us hi, .74us lo, .58us hi, .92us lo, .4us hi, 2.54us lo, .38us hi, 1.74us lo, .4us hi, .72us lo, .78us hi
Is there a way to improve the accuracy?
Here is a sample of the type of signal I'd like to emulate/produce (the bottom row, not the clock on top).
Here is my attempt on a Teensy 2.0
Here is the code:
Code:
#define TO_NEXT 1 /*PB1 = 1 */
#define TO_NEXT_HI (PORTB |= (1<<TO_NEXT))
#define TO_NEXT_LO (PORTB &= ~(1<<TO_NEXT))
#define TIMING 0.2
static inline void send_y_down ()
{
TO_NEXT_HI;
_delay_us (TIMING*3);
TO_NEXT_LO;
_delay_us (TIMING*3);
TO_NEXT_HI;
_delay_us (TIMING*2);
TO_NEXT_LO;
_delay_us (TIMING*4);
TO_NEXT_HI;
_delay_us (TIMING);
TO_NEXT_LO;
_delay_us (TIMING*12);
TO_NEXT_HI;
_delay_us (TIMING);
TO_NEXT_LO;
_delay_us (TIMING*8);
TO_NEXT_HI;
_delay_us (TIMING);
TO_NEXT_LO;
_delay_us (TIMING*3);
TO_NEXT_HI;
_delay_us (TIMING*3);
TO_NEXT_LO;
}
As you can see from the screen capture the timing isn't very accurate.
It should be: .6us hi, .6us lo, .4us hi, .8us lo, .2us hi, 2.4us lo, .2us hi, 1.4us lo, .2us hi, .6us lo, .6us hi
instead, I'm getting: .76us hi, .74us lo, .58us hi, .92us lo, .4us hi, 2.54us lo, .38us hi, 1.74us lo, .4us hi, .72us lo, .78us hi
Is there a way to improve the accuracy?
Last edited: