The code in the attachment is for an accelerator-based mouse, interfacing it to the computer via PS/2 protocol. It compiles error free, (note: it’s written for Codevision, I’ve included the hex file in the zip) however when loaded onto a uC, no movement of the mouse cursor is produced. If someone could please help me figure out what is wrong, I would greatly appreciate it.
I don’t think the 3-axis accelerator is the problem (it’s a MMA7260Q)
http://www.sparkfun.com/datasheets/Acce … Q-Rev1.pdf
it’s giving varied outputs like it’s supposed to. The three outputs of the accelerometer are inputs to ADC0, ADC1, and ADC2 of the Atmega32a http://www.atmel.com/dyn/resources/prod … oc8155.pdf
The 4 outputs of the uC go through an open-collector interface, then to a PS/2 cable from a old PS/2 mouse, then to the computer. I would like to see the mouse pointer moving in response to accelerometer tilt, however no movement is produced.
The version of the code that I’ve posted uses Port C as outputs:
#define CLK_OUT PORTC.1 // "C" in the diagram
#define DATA_OUT PORTC.6 // "D" in the diagram
#define CLK_IN PINC.3 // "B" in the diagram
#define DATA_IN PINC.4 // "A" in the diagram
.
.
.
DDRC = 0b01000010;
PORTC = 0b01000010;
I have tried this with the JTAG interface enabled and disabled. The result is the same either way.
I have also tried it with the same pins except on Port D, and changing DDRC to DDRD, etc.
Also, I have tried:
#define CLK_OUT PORTD.5 // "C" in the diagram
#define DATA_OUT PORTD.4 // "D" in the diagram
#define CLK_IN PIND.3 // "B" in the diagram
#define DATA_IN PIND.2 // "A" in the diagram
(changing DDRD and PORTD to 0x30)
Open-collector interface
http://hades.mech.northwestern.edu/imag … ircuit.PNG
The chip is brand new, I’ve checked my connections and tried changing the transistors for new ones. I left the fuses at default (internal oscillator 1 MHz).
Here is a summary of what the outputs say: (important ones in bold)
(I can also measure one of the Port D configurations if anyone wants it, but the code was originally written for Port C outputs)-I can also take pictures or video if anyone wants.
Port B: Pins 1-8 all +5V
Reset, Vcc (Pins 9, 10): +5V
GND, Xtal2, Xtal1 (pin 11, 12, 13): 0V
Port D (pins 14-21) all 0V
Port C (pins 22-29):
22: 0 V
23: 0.93 V (pin C.1, clock out)
24: 4.49 V (pin C.2)
25: 0.08 V (pin C.3, clock in)
26: 0V (pin C.4, data in)
27: 4.49V (pin C.5)
28: 0.94 V (pin C.6, data out)
29: 0
AVCC (pin 30): +5V
GND (pin 31): 0V
AREF (pin 32): +5V
Port A (pins 33-40)
Pins 33-37: 0V
Pin 38 (z): 1.99
Pin 39 (y): 1.66
Pin 40 (x): 1.65
(the last 3 vary from roughly 1.4 to 1.8 V with tilt)
Also, I should mention the outputs of Data out and Clock out. They are both +5V for all configurations except Port C with JTAG disabled, in that case both outputs are 0.18 V but drop to 0.13 after 30 seconds or so. Also, I simulated this code in Proteus and at least different parts were going high and low.