将F2812的McBSP配置成SPI主模式来读取AD芯片的转换数据,因为不需要对这个AD芯片进行配置,所以不需要发送数据给这个芯片,因此,我把MDRA接口配置成通用I/O口,来作为AD芯片的启动信号,因为有3个从设备,所以至少要有两个片选信号,将MFSRA和MFSXA配置成通用I/O口,作为片选信号,不知道这么做是否正确。。。@zhangmangui 然后先将程序下载到内部RAM,进行调试,因为不需要对这个AD芯片进行配置,所以发送伪数据来启动数据传输,但是最后读取的数据不对。。。AD芯片是下降沿读取数据。下面是McBSP的配置情况: McbspaRegs.SPCR2.bit.XRST = 0;
McbspaRegs.SPCR1.bit.RRST = 0;
McbspaRegs.SPCR2.bit.GRST = 0; McbspaRegs.SPCR1.bit.CLKSTP = 0x03; McbspaRegs.PCR.bit.CLKXP = 1;
McbspaRegs.PCR.bit.CLKRP = 1;
McbspaRegs.PCR.bit.SCLKME = 0;
McbspaRegs.PCR.bit.CLKXM = 1;
McbspaRegs.PCR.bit.FSXM = 1;
McbspaRegs.PCR.bit.FSRM = 1; McbspaRegs.XCR2.bit.XDATDLY = 1;
McbspaRegs.RCR2.bit.RDATDLY = 1;
McbspaRegs.RCR1.bit.RWDLEN1 = 2;
McbspaRegs.XCR1.bit.XWDLEN1 = 2; McbspaRegs.SRGR1.bit.CLKGDV = 0x0E;
McbspaRegs.SRGR2.bit.FSGM = 0;
McbspaRegs.SRGR2.bit.CLKSM= 1; asm(" RPT #5 || NOP "); McbspaRegs.SPCR2.bit.GRST = 1;
asm(" RPT #140 || NOP ");
McbspaRegs.SPCR2.bit.XRST = 1;
McbspaRegs.SPCR1.bit.RRST = 1;
asm(" RPT #140 || NOP "); 困扰很久了,哪位高人指导一下,不甚感激
|