Gast
#1937481
Hallo Leute ,
ich versuche gerade den Drehgeber MLX90316 (SPI version) mit den µC :
Atmega16 als auszuwerten allerdings bekomme ich unveränderlische Werte
nicht wie es sein soll, als Transistor verwende ich BUK9535-55A, und die
Auswertungsergebnisse sehen so aus :
1.Byte : 01111111
2.Byte : 11111111
3.Byte : 11111111
4.Byte : 11111111
5.Byte : 11111111
6.Byte : 11111111
7.Byte : 11111111
8.Byte : 11111111
9.Byte : 11111111
10.Byte : 11111111
ich habe das Code vereinfacht um die ersten daten zubekommen, es sieht
so aus :
//====================================================
PORTB &=~(1<<CS);
_delay_us(13);
SPDR = 0xaa;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[0] = SPDR;
x0 = r_daten[0];
_delay_us(13);
SPDR = 0xff;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[1] = SPDR;
x1 = r_daten[1];
_delay_us(13);
SPDR = 0xff;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[2] = SPDR;
x2 = r_daten[2];
_delay_us(13);
SPDR = 0xff;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[3] = SPDR;
x3 = r_daten[3];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[4] = SPDR;
x4 = r_daten[4];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[5] = SPDR;
x5 = r_daten[5];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[6] = SPDR;
x6 = r_daten[6];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[7] = SPDR;
x7 = r_daten[7];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[8] = SPDR;
x8 = r_daten[8];
_delay_us(13);
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
SPDR = 0x00;
while (!(SPSR&(1<<SPIF)));
r_daten[9] = SPDR;
x9 = r_daten[9];
_delay_us(13);
PORTB|=(1<<CS);
_delay_ms(1);
//====================================================
Das müsste doch eigentlich funktionieren, oder?
Allerdings bin ich auch kein so erfahrener programmierer und wäre froh
wenn
mir da jemand tips geben kann!
Vielen Dank