1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我正在为SPC560B60L3编写LINFLEX_0驱动程序。截至目前,尚未使用DMA。所有中断都被禁用。 Linflex_0可以配置为2组端口引脚 设置1:PB [0]中的LIN0TX和PB [1]中的LIN0RX。 PB [0]中的替代功能是3。 设置2:PB [2]中的LIN0TX和PB [3]中的LIN0RX。 PB [0]中的替代功能是1.如果我使用set2,我可以看到lin总线中的LIN信号。但是,如果我使用set1,我看不到任何lin信号。我用示波器检查了微控制器引脚,没有看到任何信号。 我正在编写如下所述的功能。 int main(void) { __DI(); //禁用所有中断 Disable_Watchdog(); MCU_Mode_Init(); MCU_PLL_Init(); / * RUN0模块配置* / ME.ME_RUN_MC [0] .B.FXOSCON = 1; ME.ME_RUN_MC [0] .B.FMPLLON = 1; ME.ME_RUN_MC [0] .B.SYSCLK = 4; ME.RUN_PC [0] .B.RUN0 = 0x1; ME.PCTL [48] .R = 0x00; ME.PCTL [49] .R = 0x00; ME.PCTL [68] .R = 0x00; / * DRUN-> RUN0转换* / MCU_SetRunMode(4); #if 0 / *非工作端口配置* / SIU.PCR [16] .B.PA = 0x3; SIU.PCR [17] .B.IBE = 0x1; SIU.PSMI [62] .B.padsEL = 0x1; #else / *工作端口配置* / SIU.PCR [18] .B.PA = 0x1; SIU.PCR [19] .B.IBE = 0x1; SIU.PSMI [62] .B.PADSEL = 0x0; #万一 LIN_InitChannel(); LIN_SendHeader(); / *启用全局中断* / __EI(); 而(1); } void LIN_InitChannel(void) { LINCR1.B.INIT = 1; / *将设备置于初始化模式* / LINCR1.B.SLEEP = 0; / *睡眠模式已清除* / LINCR1.B.MBL = 10; / * 20位同步* / LINCR1.B.MME = 1; / *启用主模式* / LINCR1.B.SFTM = 0; / *禁用自检模式* / LINCR1.B.LBKM = 0; / *启用环回模式* / LINFLEX_Ptr-> LINFBRR.B.DIV_F = 0x5; / *先写小数部分* / LINFLEX_Ptr-> LINIBRR.B.DIV_M = 0xD0; LINFLEX_Ptr-> LINCR1.B.INIT = 0; } void LIN_SendHeader(void) {LINFLEX_Ptr-> BDRL.B.DATA0 = 0xF0; LINFLEX_Ptr-> BDRL.B.DATA1 = 0XF0; LINFLEX_Ptr-> BDRL.B.DATA2 = 0XF0; LINFLEX_Ptr-> BDRL.B.DATA3 = 0XF0; LINFLEX_Ptr-> BDRM.B.DATA4 = 0XF0; LINFLEX_Ptr-> BDRM.B.DATA5 = 0XF0; LINFLEX_Ptr-> BDRM.B.DATA6 = 0XF0; LINFLEX_Ptr-> BDRM.B.DATA7 = 0XF0; LINFLEX_Ptr-> BIDR.B.ID = 9; / *没有奇偶校验的ID * / LINFLEX_Ptr-> BIDR.B.CCS = 1; / * Checksum 0-增强,1-经典* / LINFLEX_Ptr-> BIDR.B.DFL = 7; / *帧的响应部分中的数据字节数* / LINFLEX_Ptr-> BIDR.B.DIR = 1; LINFLEX_Ptr-> LINCR2.B.HTRQ = 1; / *请求标头传输* / / *如果我检查LINS位为7,这应该是理想的情况,它会挂断。 所以我检查6. Atleast我可以看到总线上的东西* / while(LINFLEX_Ptr-> LINSR.B.LINS!= 0x6); } 我只想在这里给出一个简单版本的驱动程序。重点是它在一组端口工作而在另一组端不工作。 使用的编译器是:Greenhills 6.1.6任何帮助和提示将受到高度赞赏。 问候, Saswat 以上来自于谷歌翻译 以下为原文 Hi, I am writing a LINFLEX_0 driver for SPC560B60L3. DMA is not used as of now. All interrupts are disabled. Linflex_0 can be configured in 2 sets of port pins set 1: LIN0TX in PB[0] and LIN0RX in PB[1]. Alternate function in PB[0] is 3. set 2: LIN0TX in PB[2] and LIN0RX in PB[3]. Alternate function in PB[0] is 1.If i use set2 i could see the LIN signals in the lin bus. However if i use set1 i do not see any lin signal. I checked the microcontroller pins using oscilloscope and did not see any signal. I am writing the functions used as mentioned below. int main (void) { __DI(); // Disable All interrupts Disable_Watchdog(); MCU_Mode_Init(); MCU_PLL_Init(); /* RUN0 Module Config*/ ME.ME_RUN_MC[0].B.FXOSCON=1; ME.ME_RUN_MC[0].B.FMPLLON=1; ME.ME_RUN_MC[0].B.SYSCLK=4; ME.RUN_PC[0].B.RUN0 = 0x1; ME.PCTL[48].R = 0x00; ME.PCTL[49].R = 0x00; ME.PCTL[68].R = 0x00; /* DRUN-> RUN0 Transition*/ MCU_SetRunMode(4); #if 0 /* Non Working PORT COnfiguration */ SIU.PCR[16].B.PA = 0x3; SIU.PCR[17].B.IBE = 0x1; SIU.PSMI[62].B.PADSEL = 0x1; #else /* Working PORT COnfiguration */ SIU.PCR[18].B.PA = 0x1; SIU.PCR[19].B.IBE = 0x1; SIU.PSMI[62].B.PADSEL = 0x0; #endif LIN_InitChannel ( ); LIN_SendHeader( ); /* Enable global interrupt */ __EI(); while(1); }void LIN_InitChannel( void ) { LINCR1.B.INIT=1; /* Put the Device into Initialization mode*/ LINCR1.B.SLEEP = 0; /* sleep mode cleared*/ LINCR1.B.MBL =10; /* 20 bit synch */ LINCR1.B.MME=1; /* enable master mode*/ LINCR1.B.SFTM = 0; /* disabled self test mode*/ LINCR1.B.LBKM = 0; /* Enabled loop back mode */ LINFLEX_Ptr->LINFBRR.B.DIV_F=0x5; /* Write fractional part first*/ LINFLEX_Ptr->LINIBRR.B.DIV_M=0xD0; LINFLEX_Ptr->LINCR1.B.INIT=0; }void LIN_SendHeader(void) { LINFLEX_Ptr->BDRL.B.DATA0=0xF0; LINFLEX_Ptr->BDRL.B.DATA1=0xF0; LINFLEX_Ptr->BDRL.B.DATA2=0xF0; LINFLEX_Ptr->BDRL.B.DATA3=0xF0; LINFLEX_Ptr->BDRM.B.DATA4=0xF0; LINFLEX_Ptr->BDRM.B.DATA5=0xF0; LINFLEX_Ptr->BDRM.B.DATA6=0xF0; LINFLEX_Ptr->BDRM.B.DATA7=0xF0; LINFLEX_Ptr->BIDR.B.ID=9; /* ID without Parity*/ LINFLEX_Ptr->BIDR.B.CCS=1; /* Checksum 0- enhanced, 1- classic*/ LINFLEX_Ptr->BIDR.B.DFL=7; /* Number of data bytes in the response part of the frame*/ LINFLEX_Ptr->BIDR.B.DIR=1; LINFLEX_Ptr->LINCR2.B.HTRQ = 1; /* Request header transmission */ /* If i check the LINS bit for 7, which should be the ideal case, it hangs up. So i an checking for 6. Atleast i could see something in the bus */ while(LINFLEX_Ptr->LINSR.B.LINS!=0x6); } I just tried to give a simple version of the driver here. Main point is it is working in 1 set of port and not working in the other. Compiler used is : Greenhills 6.1.6Any help and hints would be highly appreciated. Regards, Saswat |
|
相关推荐
3个回答
|
|
你好Saswat,
你使用主板和Minimodule或发现? 您是否尝试为B [0]设置OBE SIU.PCR [16] .B.OBE = 1; 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Saswat , Do you use a Motherboard and Minimodule or Discovery ? Did you try to set the OBE for B[0] SIU.PCR[16].B.OBE = 1; Best regards Erwan |
|
|
|
嗨,谢谢你的回复。我使用ST的主板。我找到了根本原因。当它们在LIN收发器中终止时,我可以在微引脚上看到Lin信号。在主板的情况下,LIN收发器连接到PCR 18和19.所以我可以看到信号。
我将PCR 16和17硬连接到LIN收发器,我也能看到那里的信号:)。 - 萨斯瓦特 以上来自于谷歌翻译 以下为原文 Hi, Thank you for the response. I use a motherboard from ST. I have found the root cause. I could see the Lin signals in the micro pin when they are terminated in a LIN transceiver. In case of the motherboard, the LIN transceiver is connected to PCR 18 and 19. So I could see the signals. I hardwired PCR 16 and 17 to the LIN transceiver an I could see the signals there as well :). - Saswat |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2732 浏览 1 评论
3241 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1810 浏览 1 评论
3650 浏览 6 评论
6038 浏览 21 评论
1339浏览 4评论
201浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
443浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
274浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 17:47 , Processed in 1.190765 second(s), Total 82, Slave 66 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号