[求助]376DSP的SPI引腳初始化問(wèn)題

關(guān)于376T初始化問(wèn)題: 采用SPI接法與2812的SPI口相連,376T的RSTI(2腳)接I/O口(高電平,與接VCC類(lèi)似,未加濾波電容)

//376片選信號(hào)高低控制 #define CH376_SPI_SCS_High {GpioDataRegs.GPFDAT.bit.GPIOF3 = 1;} #define CH376_SPI_SCS_Low {GpioDataRegs.GPFDAT.bit.GPIOF3 = 0;}

void InitGpio(void) { EALLOW; //GPIOF配置為外設(shè)功能 GpioMuxRegs.GPFMUX.bit.SPISIMOA_GPIOF0=0x1; GpioMuxRegs.GPFMUX.bit.SPISOMIA_GPIOF1=0x1; GpioMuxRegs.GPFMUX.bit.SPICLKA_GPIOF2=0x1; GpioMuxRegs.GPFMUX.bit.SPISTEA_GPIOF3=0x1; GpioMuxRegs.GPFMUX.bit.XF_GPIOF14=0x0;// I/O

GpioMuxRegs.GPFDIR.bit.GPIOF0=0x1;//output pin GpioMuxRegs.GPFDIR.bit.GPIOF1=0x0;//input pin GpioMuxRegs.GPFDIR.bit.GPIOF2=0x1;//output pin GpioMuxRegs.GPFDIR.bit.GPIOF3=0x1;//output pin GpioMuxRegs.GPFDIR.bit.GPIOF14=0x1;//out EDIS; } void InitSpi(void) { // Initialize SPI-A: SpiaRegs.SPICCR.all = 0x47;//0X1F SpiaRegs.SPICTL.all = 0x0F;//07 SpiaRegs.SPIBRR = 0x0005; //25Mhz (30M晶振,HISPCP=0X2;LOSPCP=0X0; SPI波特率=150Mhz/(5+1)=25Mhz) // SpiaRegs.SPIPRI.all = 0x10; SpiaRegs.SPICCR.all = 0xC7; PieCtrl.PIEIER6.bit.INTx1 = 1; PieCtrl.PIEIER6.bit.INTx2 = 1; }

void CH376_PORT_INIT(void) { InitGpio(); InitSpi(); CH376_SPI_SCS_High; } unsigned char Spi376Exchange(unsigned char data) { if(Spi_TxReady() == 1) { SpiaRegs.SPITXBUF = data; } if(Spi_RxReady()==1) { ReturnValue = SpiaRegs.SPIRXBUF; } return(ReturnValue); } void xEndCH376Cmd(void) //禁止ch376片選,SCS為高 { CH376_SPI_SCS_High; } void xWriteCH376Cmd(unsigned char mCmd)//向CH376寫(xiě)命令 { //為防止之前未通過(guò)xEndCH376Cmd禁止SPI片選 CH376_SPI_SCS_High; //SCS_High mDelayus(150); CH376_SPI_SCS_Low; //SCS_Low Spi376Exchange(mCmd); mDelayus(50); } void xWriteCH376Data(unsigned char mData)//向CH376寫(xiě)數(shù)據(jù) { Spi376Exchange(mData); mDelayus(40);//確保讀寫(xiě)周期大于0.6uS } unsigned char xReadCH376Data(void) //從CH376讀數(shù)據(jù) { mDelayus(40); // 確保讀寫(xiě)周期大于0.6uS return(Spi376Exchange(0xFF)); } unsigned char mInitCH376Host(void)//初始化376 { unsigned int res; // CH376_PORT_INIT();//接口硬件初始化 xWriteCH376Cmd(CMD11_CHECK_EXIST);//測(cè)試控制器與硬件之間的接口 xWriteCH376Data(0x65); res = xReadCH376Data(); xEndCH376Cmd(); if(res!=0x9A) return(ERR_USB_UNKNOWN);//通訊接口不正常

xWriteCH376Cmd(CMD11_SET_USB_MODE);//設(shè)置工作模式,SD卡模式 xWriteCH376Data(0x03); mDelayus(40); res = xReadCH376Data(); xEndCH376Cmd();

xWriteCH376Data(CMD20_SET_SDO_INT); xWriteCH376Data(0x16); xWriteCH376Data(0x90);//SD0引腳在SCS片選無(wú)效時(shí)兼做中斷請(qǐng)求輸出 xEndCH376Cmd();

if(res==CMD_RET_SUCCESS) return(USB_INT_SUCCESS);//通訊接口不正常 else return(ERR_USB_UNKNOWN); } void main(void) { InitSysCtrl(); InitPieCtrl(); InitPieVectTable(); mDelayms(150); s = mInitCH376Host();//CH376初始化,正常返回14=20,否則返回FA=250 if(Spi_TxReady() == 1) { SpiaRegs.SPITXBUF = s;} if(Spi_RxReady() == 1) { k = SpiaRegs.SPIRXBUF;} } 為什么測(cè)量引腳時(shí)發(fā)現(xiàn)SPI四個(gè)引腳全是高電平。返回值s = FA,說(shuō)明初始化未成功。這是什么原因呢?

3腳 SPI 有接么,低電平有效,需要接地,而不是接電源,我在發(fā)貼問(wèn)這個(gè)問(wèn)題


我的三腳就是接地的,只是看到典型電路里面2腳是要接VCC和濾波電容的,我的電路沒(méi)有接,直接接I/O口。利用高低電平的變換實(shí)現(xiàn)復(fù)位功能的,這樣可以么?


單片機(jī)I/O口控制復(fù)位的話,高電平保持時(shí)間在100US,拉為低電平之后需要延時(shí)50MS以上


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频