完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
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 addr STW B0,*--B15 MVKL addr,B0 MVKH addr,B0 B B0 LDW *B15++,B0 NOP 2 NOP NOP .endm*------------------------------------------------------------------------------* This is a dummy interrupt service routine used to initialize the IST.*------------------------------------------------------------------------------_vec_dummy: B B3 NOP 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模式下不能中断接收呢,请指点,谢谢! |
|
相关推荐
8 个讨论
|
|
您可能看错了,那个不是中断服务程序,是中断的配置程序。 中断服务程序是这个,我这样写的。 //SPI interrupt service routine interrupt void c_int04(void) [ //while(!(0x00000002==(SPCR0&0x00000002))); data=MCBSP_read(hMcbsp_ch0); ] |
|
|
|
|
|
lufuzi666666 发表于 2020-5-25 10:35 不好意思,确实看错了。 如果中断子程序前加了interrupt关键字是对的。 IRQ_map(IRQ_EVT_EXTINT4, IRQ_EVT_RINT0);这一句看着有问题,改成下面的试试 IRQ_map(IRQ_EVT_RINT0, 4); 修改执行后,看看MUXL[4:0]的值是不是01101? |
|
|
|
|
|
更正后正确的配置方法: 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(0x0D) to physical interrupt number IRQ_map(IRQ_EVT_RINT0,4); //Reset the ext events IRQ_reset(IRQ_EVT_RINT0); //Enable the ext events(events are disabled while resetting) IRQ_enable(IRQ_EVT_RINT0);]不过函数调用的时候,需要以下次序才能进中断。 //Config Mcbsp ConfigMcbsp(&hMcbsp_ch0); //Config Spi Receive Interrupt Setup_Spi_Interrupt(); //Start the mcbsp start_mcbsp(&hMcbsp_ch0); ConfigMcbsp(&hMcbsp_ch0);要在Setup_Spi_Interrupt();的前面,反过来就不行。 |
|
|
|
|
|
lufuzi666666 发表于 2020-5-25 10:52 在*hMcbsp_ch0 = MCBSP_open(0, MCBSP_OPEN_RESET);后调用Setup_Spi_Interrupt。 |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
697 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
607 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1069 浏览 1 评论
763 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
531 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
175浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
136浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
130浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
126浏览 12评论
GD32F303RCT6配置PA4 ADC引脚,将PA2代替key功能,PA2连接时无法实现预期功能,为什么?
72浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 00:26 , Processed in 0.995221 second(s), Total 59, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号