金牌会员
- 积分
- 1290
- 威望
- 694
- 贡献
- 362
- 兑换币
- 235
- 注册时间
- 2012-6-29
- 在线时间
- 117 小时
|
10贡献
void SPI0_Init() {
SPI0BR=0x55; //波特率2048
SPI0CR1=0x5e; //模块使能,主机模块
SPI0CR2=0x10;
}
void SPI0_Send_Data(){
cs=0;
SPI0DR=0x08;
while(!(SPI0SR_SPTEF)); //等待SPTEF 为0
cs=1;
}
SPI0_Receive_Data(){
cs=0;
LCD_set_XY(1,1);
LCD_write_char_my(font6x8[16]);
while(!(SPI0SR_SPIF));
return SPI0DR;
cs=1;
}
void main() {
Pll_Init();
DDRA=0xff;
DDRP=0xff;
LCD_init();
LCD_clear();
DDRM=0x2f;
MODRR_MODRR4=1;
SPI0_Init();
EnableInterrupts;
for(;;){
//cs=0;
//PTM_PTM3=0;
SPI0_Send_Data();
a=SPI0_Receive_Data();
LCD_set_XY(0,0);
LCD_write_char_my(font6x8[a/100+16]);
LCD_set_XY(6,0);
LCD_write_char_my(font6x8[a/10%10+16]);
LCD_set_XY(12,0);
LCD_write_char_my(font6x8[a%10+16]);
delayms(3000);
//cs=1;
//PTM_PTM3=1;
}
}
用示波器读sdi波型是0x08 为什么出来的数据总是0 求大神啊·······
|
|