Hi,
wiedermal ein SPI Problem:
muß über SPI 16bit übertragen. Klappt auch alles, hab der Logic Analyser
nachgesehen. Wenn ich den Befehl eine Sekunde später nochmal
rausschicke, bleibt er im while (!(SPSR & (1<<SPIF))) {} hängen. Ich
sehe, dass nicht geclockt wird. Was mache ich falsch?
Hier meine Init-Routine:
1 | SPI_init(void) {
|
2 | DDRB = _BV(PB1) | _BV(PB2) | _BV(PB4) | _BV(PB5) | _BV(PB6) | _BV(PB7);
|
3 | DDRB &= ~_BV(PB3);
|
4 | PORTB = _BV(PB4) | _BV(PB5) | _BV(PB6) | _BV(PB7);
|
5 | SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0) | _BV(SPR1);
|
6 | spi_status = SPSR;
|
7 | }
|
hier der Teil meine Senderoutine, der SPI anspricht
1 | PORTB &= ~_BV(PB4);
|
2 | SPI_send(highByte);
|
3 | SPI_send(lowByte);
|
4 | PORTB |= _BV(PB4);
|
was highByte und lowByte ist, ist erstmal egal, wie gesagt es wird gar
nicht geclocked...
und hier der SPI_send command
1 | void SPI_send (unsigned char data) {
|
2 | uart_puts("sending SPI\n\r");
|
3 | SPDR = data;
|
4 | uart_puts("before while...\n\r");
|
5 | while (!(SPSR & (1<<SPIF))) {}
|
6 | uart_puts("ready!\n\r"); ///< Wird nicht mehr angezeigt
|
7 | }
|
Ah ja, ich benutze eine atmega64
Gruß und Danke für alle tips
Schorsch