Hallo,
ich möchte z.B. dass an der SPI die Zahlenreihe 0x10, 0x78, 0x00, 0x10,
0xF8, 0x00 herausgeschickt wird. Ich habe es mal in der Main-Schleife so
versucht zu programmieren:
/* Set MOSI(PB2), SCK(PB1) and SS(PB0) to output,
* all others are input */
DDRB = (1<<DDB2) | (1<<DDB1) | (1<<DDB0);
/* Activate pull-up resistors for all outputs not for inputs
??Muß ich die aktivieren?*/
//PORTB &= ~(_BV(PB3));
//PORTB = _BV(PB2) | _BV(PB1) | _BV(PB0);
/* no SPI interrupt, SPI as master, MSB first, fck/16 */
SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0);
SPDR = 1;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
SPDR = 0;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
SPDR = 7;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
SPDR = 8;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
SPDR = 0;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
SPDR = 0;
while (!(SPSR & (1<<SPIF)))
;
printf("Daten %02x - %u ", SPDR, SPDR);
Als Ausgabe erhalte ich über die UART:
UART TEST
Daten 00 - 0 Daten 00 - 0 Daten 00 - 0 Daten 00 - 0 Daten 00 - 0
Daten 00- 0
Was hat das zu bedeuten?? Ich versteh auch nicht, steht in SPDR nun das
drin was ich versende oder dass, was ich vom anderen Baustein gesendet
bekomme?