程序初始化如下:
void SPI_Init(void) { byte state;
DDRS=0xD0;  TS_PTS7=1; SPI0BR=0x07; SPI0CR1=0x12; SPI0CR2=0x00; SPI0CR1_SPE=1; state=SPI0SR; }
main函数中主要是与max186通讯,现在收到的全是FF,发送的管教没波形,请教大家是不是初始化的问题?
CLR_SS(); tmp=SPI0SR; tmp=SPI0SR_SPTEF; SPI0DR=0x8E; SET_SS(); Delasm(6*10); CLR_SS(); while(SPI0SR_SPIF==0){ } data=SPI0DR; tmp=SPI0SR_SPTEF; SPI0DR=0; while(SPI0SR_SPIF==0){ } data=SPI0DR<<8; tmp=SPI0SR_SPTEF; SPI0DR=0; while(SPI0SR_SPIF==0){ } data+=SPI0DR; SET_SS(); asm NOP; asm NOP; data=data>>4;
|