2 yuyue2200 yuyue2200 于 2014.12.08 16:20 提问

C5502_MCBSP_SPI发送数据以2位只要是以二进制10结尾(2,6,a, e)的会变成11

问题如标题所述,我需要和CH374U通讯,ch374u读写时序是每次3个字节分别是ADDRESS + READ_CMD + xxxx,ADRESS + WRITE_CMD + WRITE_DATA,我配置mcbsp为spi, 单相,单帧,每帧24位。

一下是我的mcbsp的配置:

#define CFG_MCBSP_AS_SPI\
{ \
MCBSP_SPCR1_RMK( \
MCBSP_SPCR1_DLB_OFF, \
MCBSP_SPCR1_RJUST_RZF, \
MCBSP_SPCR1_CLKSTP_NODELAY,\
MCBSP_SPCR1_DXENA_OFF, \
MCBSP_SPCR1_ABIS_DISABLE, \
MCBSP_SPCR1_RINTM_RRDY, \
MCBSP_SPCR1_RSYNCERR_NO, \
MCBSP_SPCR1_RRST_DISABLE \
), \
MCBSP_SPCR2_RMK( \
MCBSP_SPCR2_FREE_YES, \
MCBSP_SPCR2_SOFT_YES, \
MCBSP_SPCR2_FRST_RESET, \
MCBSP_SPCR2_GRST_RESET, \
MCBSP_SPCR2_XINTM_XRDY, \
MCBSP_SPCR2_XSYNCERR_NO, \
MCBSP_SPCR2_XRST_DISABLE \
), \
MCBSP_RCR1_RMK( \
MCBSP_RCR1_RFRLEN1_OF(0),\
MCBSP_RCR1_RWDLEN1_24BIT \
), \
MCBSP_RCR2_RMK( \
MCBSP_RCR2_RPHASE_SINGLE,\
MCBSP_RCR2_RFRLEN2_OF(0), \
MCBSP_RCR2_RWDLEN2_8BIT, \
MCBSP_RCR2_RCOMPAND_MSB, \
MCBSP_RCR2_RFIG_YES, \
MCBSP_RCR2_RDATDLY_1BIT\
), \
MCBSP_XCR1_RMK( \
MCBSP_XCR1_XFRLEN1_OF(0),\
MCBSP_XCR1_XWDLEN1_24BIT \
), \
MCBSP_XCR2_RMK( \
MCBSP_XCR2_XPHASE_SINGLE,\
MCBSP_XCR2_XFRLEN2_OF(0), \
MCBSP_XCR2_XWDLEN2_8BIT, \
MCBSP_XCR2_XCOMPAND_MSB, \
MCBSP_XCR2_XFIG_YES, \
MCBSP_XCR2_XDATDLY_1BIT\
), \
MCBSP_SRGR1_RMK( \
MCBSP_SRGR1_FWID_OF(2), \
MCBSP_SRGR1_CLKGDV_OF(9)\
), \
MCBSP_SRGR2_RMK( \
MCBSP_SRGR2_GSYNC_FREE, \
MCBSP_SRGR2_CLKSP_RISING, \
MCBSP_SRGR2_CLKSM_INTERNAL, \
MCBSP_SRGR2_FSGM_DXR2XSR,\
MCBSP_SRGR2_FPER_OF(26) \
), \
MCBSP_MCR1_DEFAULT, \
MCBSP_MCR2_DEFAULT, \
MCBSP_PCR_RMK( \
MCBSP_PCR_XIOEN_SP, \
MCBSP_PCR_RIOEN_SP, \
MCBSP_PCR_FSXM_INTERNAL,\
MCBSP_PCR_FSRM_INTERNAL, \
MCBSP_PCR_CLKXM_OUTPUT,\
MCBSP_PCR_CLKRM_OUTPUT, \
MCBSP_PCR_SCLKME_NO, \
MCBSP_PCR_DXSTAT_0, \
MCBSP_PCR_FSXP_ACTIVELOW,\
MCBSP_PCR_FSRP_ACTIVELOW, \
MCBSP_PCR_CLKXP_RISING,\
MCBSP_PCR_CLKRP_FALLING\
), \
MCBSP_RCERA_DEFAULT, \
MCBSP_RCERB_DEFAULT, \
MCBSP_RCERC_DEFAULT, \
MCBSP_RCERD_DEFAULT, \
MCBSP_RCERE_DEFAULT, \
MCBSP_RCERF_DEFAULT, \
MCBSP_RCERG_DEFAULT, \
MCBSP_RCERH_DEFAULT, \
MCBSP_XCERA_DEFAULT, \
MCBSP_XCERB_DEFAULT, \
MCBSP_XCERC_DEFAULT, \
MCBSP_XCERD_DEFAULT, \
MCBSP_XCERE_DEFAULT, \
MCBSP_XCERF_DEFAULT, \
MCBSP_XCERG_DEFAULT, \
MCBSP_XCERH_DEFAULT \
}

以下是我的读写函数:

UINT32 spi_read(void)
{
while(!MCBSP_rrdy(mcbsp_handle))
;
return MCBSP_read32(mcbsp_handle);
}

void spi_write(const UINT32 data)
{
while(!MCBSP_xrdy(mcbsp_handle))
;
MCBSP_write32(mcbsp_handle, data);
}

调试图如下:

1个回答

heqiuya
heqiuya   2015.08.07 15:47

你用过6455的mcbsp吗?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!