#define CLK_OUT PORTC.1
#define DATA_OUT PORTC.6
#define CLK_IN PINC.3
#define DATA_IN PINC.4
C and D connects to PC via those transistors (to send data).
You must get the hardware-schematic of the circuit
Why you can't operate it with commonly available crystal ?
However you can use available higher value crystal with a Frequency-divider circuit. (eg. 100kHz crystal with Frequency-divider by 8.)
Is this helps you ?
// this interrupt should run every 20us or 1/4 period of the clock
interrupt [TIM0_COMP] void timer0_overflow(void)
void initialize(void)
{
Button0pushed = 1050;
Button1pushed = 1050;
ADMUX = 0b01000000; //ADLAR is not set
ADCSRA = 0b11000111; //Enable & Start ADC w/ division factor of 128
OCR0=5; //20 uSec
TIMSK=2; //turn on timer 0 cmp-match ISR
TCCR0=0b00001011; //prescalar to 64 and Clr-on-match
.
.
The Data and Clock lines are both open collector. A resistor is connected between each line and +5V, so the idle state of the bus is high. When the keyboard or mouse wants to send information, it first checks the Clock line to make sure it's at a high logic level. If it's not, the host is inhibiting communication and the device must buffer any to-be-sent data until the host releases Clock. The Clock line must be continuously high for at least 50 microseconds before the device can begin to transmit its data.
As I mentioned in the previous section, the keyboard and mouse use a serial protocol with 11-bit frames. These bits are:
1 start bit. This is always 0.
8 data bits, least significant bit first.
1 parity bit (odd parity).
1 stop bit. This is always 1.
The keyboard/mouse writes a bit on the Data line when Clock is high, and it is read by the host when Clock is low.
A clock frequency in this range can easily be generated by the use of a timer in your code with almost any system clock, therefore frequency of the µC is largely irrelevant with the proper selection of a timer prescaler value.
is this an HID, Human Interface Device
Why not implement a serial port?
I have several accelerometer interface examples floating around here somewhere. I 'll post them when I find them.
you must need to know Clock-source used for original design; since it was used to calculate PS/2 clock signal
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?