Gast
#438772
Moin!
Bin hier schon wieder am verzweifeln. Habe einen alten Sourcecode, der
ein Byte in Bits aufteilt, und sie einzelnd seriell sendet auf SPI
umgebaut...
folgender Sourcecode:
void SPI_MasterInit(int a)
{
/* Set MOSI and SCK output, all others input */
DDR_SPI = 0x60;
/* Enable SPI, Master, set clock rate fck/16 */
SPCR = 0x59;
}
void lcd_cmd(unsigned char value)
{
PORT(LCD_PORT) &= ~(_BV(LCD_SD)); //command bit -> 0
PORT(LCD_PORT) |= _BV(LCD_SC);
PORT(LCD_PORT) &= ~(_BV(LCD_CS));
/* Start transmission */
SPDR = value;
/* Wait for transmission complete */
while(!(SPSR & (1<<SPIF)));
}
void lcd_data(unsigned char cData)
{
PORT(LCD_PORT) &= ~(_BV(LCD_CS)); //CS to 0
//SCLK to 0
PORT(LCD_PORT) |= _BV(LCD_SD); //data -> 1
PORT(LCD_PORT) |= _BV(LCD_SC); //output bit
/* Start transmission */
SPDR = cData;
/* Wait for transmission complete */
while(!(SPSR & (1<<SPIF)))
;
}
Wahrscheinlich irgendein blöder Anfängerfehler, aber ich sitz da schon
stunden dran...
Das Display ist an das SPI angeschlossen, der Controller ist ein Mega128
ChriZi