Ich habe nun alle strings mit PSTR übergeben. Das löst das Problem
allerdings auch nicht. Nach etwas herumprobieren und auskommentieren,
habe ich herausgefunden, dass der eigentlich Knackpunkt wohl die
spi_send_byte() Funktion ist. Warum funktioniert die ein paar Mal, weil
das Display wird ja initialisiert und danach plötzlich nicht mehr?
1 | #include "../header/spi.h"
|
2 | void spi_init()
|
3 | {
|
4 | CSB_DDR |= (1<<CSB_PIN);
|
5 | CSB_PORT |= (1<<CSB_PIN);
|
6 | /* Set MOSI and SCK output, all others input */
|
7 | DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK);
|
8 | /* Enable SPI, Master, set clock rate fck/16 */
|
9 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);
|
10 | SPSR = (1<<SPI2X);
|
11 | }
|
12 |
|
13 | void spi_send_byte(uint8_t data)
|
14 | {
|
15 | CSB_PORT &= ~(1<<CSB_PIN);
|
16 | /* Start transmission */
|
17 | SPDR = data;
|
18 | /* Wait for transmission complete */
|
19 | while(!(SPSR & (1<<SPIF)));
|
20 | CSB_PORT |= (1<<CSB_PIN);
|
21 | _delay_us(45);
|
22 | if (data == 0x1 || data == 0x2 || data == 0x3)
|
23 | {
|
24 | _delay_us(45);
|
25 | }
|
26 | }
|