完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用SPC560D-DIS Discovery板进行开发和SPC5工作室。
我已经为FlexCAN测试导入了测试应用程序'SPC560Dxx OS-Less CAN Test Application for Discovery'。在此FlexCAN0用于环回模式。它正在循环返回模式下工作。 但是在禁用环回模式后,它不会在CANTx上传输数据。 TX邮箱的代码保持为0x0C并生成错误处理程序。设置TWRNINT,BIT0ERR,BOFFINT和ERRINT的错误标志。 我用下面的结构传输数据, / * CAN TX消息结构* / txmsg.IDE = CAN_IDE_EXT; txmsg.RTR = CAN_RTR_DATA; txmsg.LENGTH = 8; txmsg.data32 [0] = 0x55AA55AA; txmsg.data32 [1] = 0x00FF00FF; 初始化程序如下, uint8_t mb_index = 0; uint8_t id = 0; / *进入初始化模式。 * / canp-&gt; state = CAN_STARTING; / *时钟激活。* / #if SPC5_CAN_USE_FLEXCAN0 / *设置外设时钟模式。* / if(&amp; CAND1 == canp){ SPC5_FLEXCAN0_ENABLE_CLOCK(); #if!SPC5_CAN_FLEXCAN0_USE_EXT_CLK canp-> flexcan-&gt; CR.R | = CAN_CTRL_CLK_SRC; #万一 } / *启用设备。* / canp-> flexcan-&gt; MCR.R&amp; = ~CAN_MCR_MDIS; / * *每MB单独过滤,禁用帧自我接收, *禁用FIFO,启用SuperVisor模式。 * / #if SPC5_CAN_USE_FLEXCAN0 if(&amp; CAND1 == canp) canp-&gt; flexcan-&gt; MCR.R | = CAN_MCR_SUPV | CAN_MCR_MAXMB(SPC5_FLEXCAN0_MB - 1); #万一 canp-> flexcan-&gt; CR.R | = CAN_CTRL_TSYN | CAN_CTRL_RJW(3); / * TX MB初始化。* / #if SPC5_CAN_USE_FLEXCAN0 if(&amp; CAND1 == canp){ for(mb_index = 0; mb_index&lt;(SPC5_FLEXCAN0_MB - CAN_RX_MAILBOXES); mb_index ++){ canp-&gt; flexcan-&gt; BUF [mb_index + CAN_RX_MAILBOXES] .CS.B.CODE = 8U; } } #万一 / *解锁消息缓冲区。* / (void)canp-> flexcan-&gt; TIMER.R; / * MCR初始化。* / canp-&gt; flexcan-&gt; MCR.R | = canp-&gt; config-&gt; mcr; / * CTRL初始化。* / canp-&gt; flexcan-&gt; CR.R | = canp-&gt; config-&gt; ctrl; / *中断源初始化。* / canp-&gt; flexcan-&gt; MCR.R | = CAN_MCR_WRN_EN; canp-&gt; flexcan-&gt; CR.R | = CAN_CTRL_BOFF_MSK | CAN_CTRL_ERR_MSK | CAN_CTRL_TWRN_MSK | CAN_CTRL_RWRN_MSK; / * RX MB初始化。* / for(id = 0; id&lt; CAN_RX_MAILBOXES; id ++){ canp-> flexcan-&gt; BUF [id] .CS.B.CODE = 0U; if(canp-&gt; config-&gt; RxFilter [id] .scale){ canp-> flexcan-&gt; BUF [id] .CS.B.IDE = 1U; canp-&gt; flexcan-&gt; BUF [id] .ID.R = canp-&gt; config-&gt; RxFilter [id] .register1; } 其他{ canp-&gt; flexcan-&gt; BUF [id] .CS.B.IDE = 0U; canp-&gt; flexcan-&gt; BUF [id] .ID.B.STD_ID = canp-&gt; config-&gt; RxFilter [id] .register1; canp-&gt; flexcan-&gt; BUF [id] .ID.B.EXT_ID = 0U; } / * RX MB初始化。* / canp-> flexcan-&gt; BUF [id] .CS.B.CODE = 4U; } canp-> flexcan-> RXGMASK.R = 0x0FFFFFFF; / *启用MB中断。* / #if SPC5_CAN_USE_FLEXCAN0 if(&amp; CAND1 == canp){ if(SPC5_FLEXCAN0_MB == 32){ canp-&gt; flexcan-&gt; IMRL.R = 0xFFFFFFFF; } 否则if(SPC5_FLEXCAN0_MB == 64){ canp-&gt; flexcan-&gt; IMRL.R = 0xFFFFFFFF; canp-&gt; flexcan-&gt; IMRH.R = 0xFFFFFFFF; } } #万一 / * CAN BUS同步。* / canp-> flexcan-> MCR.B.HALT = 0; 这个配置是否缺失/错误? 同样在FlexCAN Buad上,我使用48MHz的总线clk,PRESDIV = 3,PSEG1 = 2,PSEG2 = 7和PROPSEG = 2。然后Sclock将是48MHz /(3 + 1)= 12MHz并且FlexCAN buad是12MHz / 15 = 800kbps。它是否正确? 以上来自于谷歌翻译 以下为原文 I am using SPC560D-DIS Discovery board for development and SPC5 studio. I have imported test application 'SPC560Dxx OS-Less CAN Test Application for Discovery' for FlexCAN testing. In this FlexCAN0 is used in loop back mode. It is working in loop back mode. But after disabling loop back mode, it is not transmitting data on CANTx. The code for TX mailbox remain as 0x0C and error handler is generating. Error flags for TWRNINT, BIT0ERR, BOFFINT and ERRINT are set. I used below structure to transmit data, /* CAN TX Message structure */ txmsg.IDE = CAN_IDE_EXT; txmsg.RTR = CAN_RTR_DATA; txmsg.LENGTH = 8; txmsg.data32[0] = 0x55AA55AA; txmsg.data32[1] = 0x00FF00FF; And initialization routine is as below, uint8_t mb_index = 0; uint8_t id = 0; /* Entering initialization mode. */ canp->state = CAN_STARTING; /* Clock activation.*/ #if SPC5_CAN_USE_FLEXCAN0 /* Set peripheral clock mode.*/ if(&CAND1 == canp) { SPC5_FLEXCAN0_ENABLE_CLOCK(); #if !SPC5_CAN_FLEXCAN0_USE_EXT_CLK canp->flexcan->CR.R |= CAN_CTRL_CLK_SRC; #endif } /* Enable the device.*/ canp->flexcan->MCR.R &= ~CAN_MCR_MDIS; /* * Individual filtering per MB, disable frame self reception, * disable the FIFO, enable SuperVisor mode. */ #if SPC5_CAN_USE_FLEXCAN0 if(&CAND1 == canp) canp->flexcan->MCR.R |= CAN_MCR_SUPV | CAN_MCR_MAXMB(SPC5_FLEXCAN0_MB - 1); #endif canp->flexcan->CR.R |= CAN_CTRL_TSYN | CAN_CTRL_RJW(3); /* TX MB initialization.*/ #if SPC5_CAN_USE_FLEXCAN0 if(&CAND1 == canp) { for(mb_index = 0; mb_index < (SPC5_FLEXCAN0_MB - CAN_RX_MAILBOXES); mb_index++) { canp->flexcan->BUF[mb_index + CAN_RX_MAILBOXES].CS.B.CODE = 8U; } } #endif /* Unlock Message buffers.*/ (void) canp->flexcan->TIMER.R; /* MCR initialization.*/ canp->flexcan->MCR.R |= canp->config->mcr; /* CTRL initialization.*/ canp->flexcan->CR.R |= canp->config->ctrl; /* Interrupt sources initialization.*/ canp->flexcan->MCR.R |= CAN_MCR_WRN_EN; canp->flexcan->CR.R |= CAN_CTRL_BOFF_MSK | CAN_CTRL_ERR_MSK | CAN_CTRL_TWRN_MSK | CAN_CTRL_RWRN_MSK; /* RX MB initialization.*/ for (id = 0; id < CAN_RX_MAILBOXES; id++) { canp->flexcan->BUF[id].CS.B.CODE = 0U; if (canp->config->RxFilter[id].scale) { canp->flexcan->BUF[id].CS.B.IDE = 1U; canp->flexcan->BUF[id].ID.R = canp->config->RxFilter[id].register1; } else { canp->flexcan->BUF[id].CS.B.IDE = 0U; canp->flexcan->BUF[id].ID.B.STD_ID = canp->config->RxFilter[id].register1; canp->flexcan->BUF[id].ID.B.EXT_ID = 0U; } /* RX MB initialization.*/ canp->flexcan->BUF[id].CS.B.CODE = 4U; } canp->flexcan->RXGMASK.R = 0x0FFFFFFF; /* Enable MBs interrupts.*/ #if SPC5_CAN_USE_FLEXCAN0 if(&CAND1 == canp) { if(SPC5_FLEXCAN0_MB == 32) { canp->flexcan->IMRL.R = 0xFFFFFFFF; } else if(SPC5_FLEXCAN0_MB == 64) { canp->flexcan->IMRL.R = 0xFFFFFFFF; canp->flexcan->IMRH.R = 0xFFFFFFFF; } } #endif /* CAN BUS synchronization.*/ canp->flexcan->MCR.B.HALT = 0; Is any configuration is missing / wrong in this? Also on FlexCAN Buad, I used bus clk of 48MHz, and PRESDIV=3, PSEG1=2, PSEG2=7 and PROPSEG=2. Then Sclock will be 48MHz/(3+1) = 12MHz and FlexCAN buad is 12MHz/15 = 800kbps. Is this correct? |
|
相关推荐
3个回答
|
|
你好Megha,
您是否尝试在Pinmap向导CAN0RX和CAN0TX上进行配置? 我们应该通过示波器看到你的CAN帧。 无论如何,我们将尽快发布没有LOOBACK模式的应用程序。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Megha , Did you you try to configure on the Pinmap Wizard CAN0RX and CAN0TX ? We should seen your CAN Frames by oscilloscope. Anyway, as soon as possible, we will post an application without LOOBACK mode. Best Regards Erwan |
|
|
|
谢谢Erwan的回复。
是的,我已经从Pinmap向导配置了CANTX和CANRX。 我已将CANTX引脚PB0配置为AF1。对于CANRX引脚PB1,CAN接收没有AF1-AF3选项。所以我将CANRX引脚PB1配置为MODE_INPUT_PULLUP。这种配置是否正确? 我在示波器上观察了CANTX引脚。根据附加的快照,数据正在该引脚上,但它不是按照所需的波特率。此外,我在BUF8和BUF9中发送了两次Tx消息,但在CANTX线路上,我可以在示波器上看到连续数据,同时为BUF8和BUF9生成错误中断。 我还观察了一件事,当我只配置CANTX引脚而不是CANRX引脚时,CANTX引脚上没有数据。 CANTX和CANRX还有其他配置吗? --Megha 以上来自于谷歌翻译 以下为原文 Thanks Erwan for your reply. Yes, I have configured CANTX and CANRX from Pinmap wizard. I have configured CANTX pin PB0 as AF1. For CANRX pin PB1, there is no option as AF1-AF3 for CAN receive. So I have configured CANRX pin PB1 as MODE_INPUT_PULLUP. Is this configurations are correct? I observed CANTX pin on oscilloscope. Data is coming on that pin as per attached snapshot but it is not as per desired baud. Also I have sent Tx message twice in BUF8 and BUF9 but on CANTX line I can see continuous data on oscilloscope while error interrupt is generated for BUF8 and BUF9. I observed one more thing, when I configured just CANTX pin and not CANRX pin then data is not coming on CANTX pin. Is there any other configuration for CANTX and CANRX? --Megha |
|
|
|
你好Megha
我有这样的问题,我可以猜测时钟无法正常工作 我使用这个buadrate为我的董事会请设置这些参数: 在外部时钟振荡器中设置CAN时钟= 16.00 MHz PressDive = 1,PropSeg = 0,PSEG1 = 5,PSEG2 = 7波特率= 500k 我不知道你的芯片型号是什么,但如果你的MCU有一个多引脚用于CANRX你可以设置CANRX引脚在其他引脚的设置 (您可以在参考手册RM0017的第338页中找到)。 最好的祝福 Nazerian Vanima 以上来自于谷歌翻译 以下为原文 Hello Megha I Have this like this problem in can i guess the can Clock not worked correctlly i use this buadrate for my board please set these prameters : Set your CAN Clock in External Clock Oscillator = 16.00 MHz PressDive =1 , PropSeg=0 , PSEG1=5 , PSEG2=7 Baudrate =500k i do not know what is your chip model but if your MCU have a multi Pin For CANRX you can set the CANRX Pin in other pin's with set ( you can find in Page 338 of Refrence manual RM0017). Best Regards Nazerian Vanima |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2655 浏览 1 评论
3216 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1790 浏览 1 评论
3619 浏览 6 评论
5997 浏览 21 评论
946浏览 4评论
1319浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
591浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1309浏览 3评论
1369浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 13:21 , Processed in 1.086659 second(s), Total 52, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号