|  | 
 
悬赏50资产未解决
 
| 为什么我的avr单片机的spi串口只能发送一次数据,就是spif只能置位一次?各项配置都没问题程序如下 #define Select  CLRBIT(PORTB,PB2)
 #define UnSelect SETBIT(PORTB,PB2)
 
 
 uint8 SendByte(uint8 Order)   //单字传送
 {
 uint8 clear;
 Select;
 SPDR=Order;
 while(!(SPSR&(1<<SPIF)));
 clear=SPSR;
 UnSelect;
 return SPDR;
 }
 
 
 
 
 void Port_Init(void)        //初始化函数
 {
 uint8 u8_Data[3];
 SPCR|=(1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0);
 DDRB|=(1<<PB3)|(1<<PB5)|(1<<PB2);
 DDRC=0xff;
 PORTC=0XFF;
 // Select;
 // Reset;
 // _delay_ms(1);        //选中并复位
 // UnReset;        //不选中,不复位
 // UnSelect;
 SendByte(0xff);
 SendByte(0xff);
 // Command(u8_Data,0xFF,0xFF,0xFF,0xFE); //发送同步指令
 }
 | 
 |