TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320C6713 MCBSP0 SPI Slave模式 接收进不了中断

TI专家,各位朋友:
    SPI slave模式CPU轮询可以接收到数据,并且是正确的,但是 配置为中断接收却进步了中断

中断配置代码:

void Setup_Spi_Interrupt(void)
{

	//point to the IRQ vector table
	IRQ_setVecs(vectors);	//Globally enable interrupts
 	IRQ_globalEnable();	//Enable NMI interrupt
 	IRQ_nmiEnable();	//Map McBSP0 RINT0 events(0x0c) to physical interrupt number	IRQ_map(IRQ_EVT_EXTINT4, IRQ_EVT_RINT0);	//Reset the ext events
	IRQ_reset(IRQ_EVT_EXTINT4);
	
	//Enable the ext events(events are disabled while resetting)IRQ_enable(IRQ_EVT_EXTINT4);

}

中断向量表:

*------------------------------------------------------------------------------
* Global symbols defined here and exported out of this file
*------------------------------------------------------------------------------.global _vectors.global _c_int00.global _vector1.global _vector2.global _vector3.global _c_int04.global _vector5.global _vector6.global _vector7.global _vector8.global _vector9.global _vector10.global _vector11.global _vector12.global _vector13.global _vector14 ; Hookup the c_int14 ISR in main().global _vector15

*------------------------------------------------------------------------------
* Global symbols referenced in this file but defined somewhere else. 
* Remember that your interrupt service routines need to be referenced here.
*------------------------------------------------------------------------------.ref _c_int00

*------------------------------------------------------------------------------
* This is a macro that instantiates one entry in the interrupt service table.
*------------------------------------------------------------------------------
VEC_ENTRY .macro addrSTWB0,*--B15MVKL  addr,B0MVKH  addr,B0BB0LDW*B15++,B0NOP2NOPNOP.endm


*------------------------------------------------------------------------------
* This is a dummy interrupt service routine used to initialize the IST.
*------------------------------------------------------------------------------
_vec_dummy:BB3NOP  5

*------------------------------------------------------------------------------
* This is the actual interrupt service table (IST). It is properly aligned and
* is located in the subsection .text:vecs. This means if you don't explicitly
* specify this section in your linker command file, it will default and link
* into the .text section. Remember to set the ISTP register to point to this
* table.
*------------------------------------------------------------------------------
 .sect ".text:vecs"
 .align 1024

_vectors:
_vector0:VEC_ENTRY _c_int00;RESET
_vector1:VEC_ENTRY _vec_dummy  ;NMI
_vector2:VEC_ENTRY _vec_dummy  ;RSVD
_vector3:VEC_ENTRY _vec_dummy
_vector4:VEC_ENTRY _c_int04 
_vector5:VEC_ENTRY _vec_dummy
_vector6:VEC_ENTRY _vec_dummy
_vector7:VEC_ENTRY _vec_dummy
_vector8:VEC_ENTRY _vec_dummy
_vector9:VEC_ENTRY _vec_dummy
_vector10:  VEC_ENTRY _vec_dummy
_vector11:  VEC_ENTRY _vec_dummy
_vector12:  VEC_ENTRY _vec_dummy
_vector13:  VEC_ENTRY _vec_dummy
_vector14:  VEC_ENTRY _vec_dummy ; Hookup the c_int14 ISR in main()
_vector15:  VEC_ENTRY _vec_dummy

*------------------------------------------------------------------------------


********************************************************************************
* End of vecs.asm
********************************************************************************

MCBSP0配置:

void ConfigMcbsp(MCBSP_Handle *hMcbsp_ch0)
{
	MCBSP_Config MyMcbspConfig;
	
	*hMcbsp_ch0 = MCBSP_open(0, MCBSP_OPEN_RESET);
	
	//串口控制寄存器 
	MyMcbspConfig.spcr= (Uint32)	((MCBSP_SPCR_XINTM_XRDY<< _MCBSP_SPCR_XINTM_SHIFT)	|(MCBSP_SPCR_RINTM_RRDY<< _MCBSP_SPCR_RINTM_SHIFT)	|(MCBSP_SPCR_CLKSTP_DELAY<< _MCBSP_SPCR_CLKSTP_SHIFT  )	|(MCBSP_SPCR_DLB_OFF<< _MCBSP_SPCR_DLB_SHIFT)//|( MCBSP_SPCR_XRST_1<< _MCBSP_SPCR_XRST_SHIFT)	//|( MCBSP_SPCR_RINTM_FRM<< _MCBSP_SPCR_RINTM_SHIFT)	);
	//接收控制寄存器
	MyMcbspConfig.rcr = (Uint32)	((MCBSP_RCR_RPHASE_SINGLE<< _MCBSP_RCR_RPHASE_SHIFT)	|(MCBSP_RCR_RCOMPAND_DEFAULT << _MCBSP_RCR_RCOMPAND_SHIFT )//MSB	|(MCBSP_RCR_RFIG_YES<< _MCBSP_RCR_RFIG_SHIFT)	|(MCBSP_RCR_RDATDLY_0BIT<< _MCBSP_RCR_RDATDLY_SHIFT  )	|(MCBSP_RCR_RWDLEN1_8BIT<< _MCBSP_RCR_RWDLEN1_SHIFT  )//8BIT	|(MCBSP_RCR_RFRLEN1_DEFAULT  << _MCBSP_RCR_RFRLEN1_SHIFT  )	);
	//发送控制寄存器
	MyMcbspConfig.xcr = (Uint32)	((MCBSP_XCR_XPHASE_SINGLE<< _MCBSP_XCR_XPHASE_SHIFT)	|(MCBSP_XCR_XCOMPAND_DEFAULT << _MCBSP_XCR_XCOMPAND_SHIFT )//MSB
 						//|(MCBSP_XCR_XCOMPAND_8BITLSB << _MCBSP_XCR_XCOMPAND_SHIFT )//lSB	|(MCBSP_XCR_XFIG_YES<< _MCBSP_XCR_XFIG_SHIFT)	|(MCBSP_XCR_XDATDLY_0BIT<< _MCBSP_XCR_XDATDLY_SHIFT  )	|(MCBSP_XCR_XWDLEN1_8BIT<< _MCBSP_XCR_XWDLEN1_SHIFT  )//8BIT	|(MCBSP_XCR_XFRLEN1_DEFAULT  << _MCBSP_XCR_XFRLEN1_SHIFT  )	);
	//采样率产生寄存器
	MyMcbspConfig.srgr= (Uint32)	((MCBSP_SRGR_CLKSM_INTERNAL  << _MCBSP_SRGR_CLKSM_SHIFT)	|(MCBSP_SRGR_FSGM_DXR2XSR<< _MCBSP_SRGR_FSGM_SHIFT)//|(MCBSP_SRGR_FSGM_FSG<< _MCBSP_SRGR_FSGM_SHIFT)//ERROR	|(MCBSP_SRGR_CLKGDV_OF(0)<< _MCBSP_SRGR_CLKGDV_SHIFT  )//20M	);
	//引脚控制 
	MyMcbspConfig.pcr = (Uint32)	((MCBSP_PCR_XIOEN_SP<< _MCBSP_PCR_XIOEN_SHIFT)	|(MCBSP_PCR_RIOEN_SP<< _MCBSP_PCR_RIOEN_SHIFT)	|(MCBSP_PCR_FSXM_EXTERNAL<< _MCBSP_PCR_FSXM_SHIFT)	|(MCBSP_PCR_FSRM_EXTERNAL<< _MCBSP_PCR_FSRM_SHIFT)	|(MCBSP_PCR_CLKXM_INPUT<< _MCBSP_PCR_CLKXM_SHIFT)//slave	|(MCBSP_PCR_CLKRM_INPUT<< _MCBSP_PCR_CLKRM_SHIFT)//slave	|(MCBSP_PCR_FSXP_ACTIVELOW<< _MCBSP_PCR_FSXP_SHIFT)	|(MCBSP_PCR_FSRP_ACTIVELOW<< _MCBSP_PCR_FSRP_SHIFT)	//|(MCBSP_PCR_CLKXP_RISING<< _MCBSP_PCR_CLKXP_SHIFT  )	|(MCBSP_PCR_CLKXP_FALLING<< _MCBSP_PCR_CLKXP_SHIFT)	|(MCBSP_PCR_CLKRP_FALLING<< _MCBSP_PCR_CLKRP_SHIFT)	);	
	MCBSP_config(*hMcbsp_ch0, &MyMcbspConfig);
} /* end config_mcbsp */

是否在slave模式下不能中断接收呢,请指点,谢谢!

Shine:

试试中断函数名用interrupt关键字定义一下。interrupt void Setup_Spi_Interrupt(void)

wei lee1:

回复 Shine:

您可能看错了,那个不是中断服务程序,是中断的配置程序。

中断服务程序是这个,我这样写的。

//SPI interrupt service routineinterrupt voidc_int04(void){//while(!(0x00000002==(SPCR0&0x00000002)));data=MCBSP_read(hMcbsp_ch0);}

wei lee1:

回复 Shine:

现在又遇到一个新问题,我接收的中断方式由“RINT is driven by RRDY (end-of-word) and end-of-frame in A-bis mode.”修改为“RINT is generated by a new frame synchronization.”,无中断触发。

具体的SPCR寄存器的描述如下图:

  

Shine:

回复 wei lee1:

在*hMcbsp_ch0 = MCBSP_open(0, MCBSP_OPEN_RESET);后调用Setup_Spi_Interrupt。

Shine:

回复 wei lee1:

先看一下IFR寄存器相应位有没有置1?看中断有没有发生。

Kaixue Hao:

你好,我在用6713作为SPI也遇到了类似的问题,就是rrdy位一直不能置1.

您可以把您McBSP的程序和SPI主机的配置发我邮箱吗?谢谢!邮箱:haokx1993@163.com

赞(0)
未经允许不得转载:TI中文支持网 » TMS320C6713 MCBSP0 SPI Slave模式 接收进不了中断
分享到: 更多 (0)