测试SPI读取ID一读取就跑飞[AppleScript]
纯文本查看 复制代码
#include "spi.h"#include "sst25.h"void delay(unsigned long ms); //延时毫秒函数void SYS_Init(); //系统时钟初始化函数unsigned long int id1,id2;int main( void ){ // Stop watchdog
timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; SYS_Init(); SPI_Init(); _EINT(); while(1){ id1=Read_ID();_NOP();id2=Jedec_ID_Read() ; _NOP(); }}
这是主函数,请教!
//系统时钟初始化函数void SYS_Init(){ unsigned int i; WDTCTL=WDTPW+WDTHOLD; //关闭看门狗 FLL_CTL0 |= XCAP18PF; // Set load capacitance FLL_CTL1 |=FLL_DIV1; //FLL+ Divide Px.x/ACLK 1 FLL_CTL1 &=~XT2OFF; //XT2有效 8MHz while((IFG1&OFIFG)!=0) //当OFIFG等于0的时候结束,说明晶体振荡器正常工作了 { IFG1 &=~OFIFG; //清除晶体振荡器失效标志OFIFG标志 // delay(); //等待50us for(i = 400;i>0; i--); } FLL_CTL1 |=SELM_XT2 ; //Select XT2 for CPU MCLK FLL_CTL1 |=FLL_DIV_8; //FLL+ Divide Px.x/ACLK By 8 每个时钟周期为1us FLL_CTL1 |=SELM1+SELS; //MCLK Source Select 1 Peripheral Module Clock Source:SMCLK
不是程序就得换个晶振看看了
一周热门 更多>