char spi_transfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
{
};
return SPDR; // return the received byte
}
错误: 只要写入的数据 bit7 = 1 , 读回来的数字就多了6F?!!
例如:在0x52地址写入0xBC(0x52, 0xBC),然后读取0x52地址的值是:FFFFFFBC
数据类型在程序是不同的
之前用是int类型
该为Unsigned类型即可