我使用的芯片是56F8014,使用PE生成的SPI驱动程序。
在调用驱动发送数据时,我在SCLK和MOSI上都测不到任何数据波形。
各位大侠指点一下。
void SM1_Init(void) { /* SPI_SCR: SPR2=1,SPR1=0,SPR0=1,DSO=1,ERRIE=0,MODFEN=1,SPRIE=0,SPMSTR=1,CPOL=0,CPHA=1,SPE=0,SPTIE=0,SPRF=0,OVRF=0,MODF=1,SPTE=0 */ setReg(SPI_SCR,46402); /* Set control register */ /* SPI_DSR: WOM=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,DS3=0,DS2=1,DS1=1,DS0=1 */ setReg(SPI_DSR,7); /* Set data size and control register */ SerFlag = 0; /* Reset all flags */ EnUser = TRUE; /* Enable device */ HWEnDi(); /* Enable/disable device according to the status flags */ } byte SM1_SendChar(SM1_TComData Chr) { if ((!getRegBit(SPI_SCR,SPTE))||(SerFlag&FULL_TX)) { /* Is last character send? */ return ERR_TXFULL; /* If no then return error */ } if (EnUser) { /* Is device enabled? */ setReg(SPI_DTR,Chr); /* If yes, send character */ } else { BufferWrite = Chr; /* If no, save character */ SerFlag |= FULL_TX; /* ...and set flag */ } return ERR_OK; /* OK */ }
void main(void) { /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/
/* Write your code here */ for(;;) { SM1_SendChar(0x55); } } |