完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在尝试连接MCP2515到Link KIT板(兼容ARDUINO)。我使用的是LinkIt ONE(数字引脚工作在3.3v)+电平转换器(TXB0108PWR)+CAN模块,板上有MCP2515和TJA1050。我不能完全确定我的初始化是错的还是好的。每次读取寄存器值时,它会返回不同的响应。在读取之间,我不调用任何SPI命令,所以理论上寄存器值不应该改变。我尝试过使用SPI命令(0xC0)和硬件(RST管脚上的低电平)在通电后使用两种类型的复位。我都得到同样的结果。我用RPI测试了我的MCP2515,所有的工作都很好,所以IC没有被破坏。我还检查了SPI是否正确地使用了回环测试,并且它通过了。现在我将分享一些关于我的方案的信息.1)连接:我不能附加连接方案,但是有一个表:LinkIt One Level.or(TXB0108PWR)MCP25153v3 VA-5v VB+5V,nRSTGND GND GNDSCK A2(3.3v)<->B2(5v)SCK MISO A4(3)。3v)-lt;->B4(5v)-B4(5v)-SOMOSI A5(3.3v)-lt->B5(5v)-B5(5v)-B5(5v)SIPIN9(CS 9(CS)A9(CS)A9(CS)A6(3.3v)-
以上来自于百度翻译 以下为原文 Hello, I'm trying to connect mcp2515 to LinkIt ONE board(compatibile with Arduino). I'm using LinkIt ONE(digital pins operates at 3.3v) + Level translator(TXB0108PWR) + CAN module with MCP2515 and TJA1050 on board. I cannot fully determinate whether my initializations goes wrong or good. Each time I read register value it returns different response. Between reads I don't call any SPI command so theoretically registers values shouldn't change. I've tried to use two types of reset after power-up using SPI command(0xC0) and hardware(low-level on RST pin). After both i get same results. I did tested my MCP2515 with RPi and everything worked fine there so IC is not broken. I've also checked whether SPI works properly with loopback test - and it passed. Now I will share some informations about my scheme. 1)Connections: I cannot attach connections scheme but, so there's table: LinkIt ONE Level translator(TXB0108PWR ) MCP2515 3v3 VA --- 5v VB +5V, nRST GND GND GND SCK A2(3.3v) <-> B2(5v) SCK MISO A4(3.3v) <-> B4(5v) SO MOSI A5(3.3v) <-> B5(5v) SI PIN9(CS) A6(3.3v) <-> B6(5v) nCS PIN2(INT) A3(3.3v) <-> B3(5v) nINT 2)My code looks like this: a)Each SPI command call: digitalWrite(CS_PIN, LOW); ..... digitalWrite(CS_PIN, HIGH); for example readRegister: byte readRegister(const byte reg_addr){ byte ret; digitalWrite(CS_PIN, LOW); SPI.transfer(MCP_READ); SPI.transfer(reg_addr); ret = SPI.transfer(0x00); digitalWrite(CS_PIN, HIGH); return ret; } b)initialization(can_mode ANY, can_speed 250Kbps, can_clk 16MHz): byte initialize( const byte can_mode, const byte can_speed, const byte can_clk){ byte result; softReset();//using SPI command if(!setCtrlRegister(CANCTRL_MODE_CONFIG)) //entering config mode by using bit modify return FAIL; if(!configRate(can_speed, can_clk)) //setting registers: MCP_CNF1, MCP_CNF2, MCP_CNF3 return result; initBuffers();//Initializig masks, filters. Clearing transmit buffers modifyRegister(MCP_CANINTE, 0x03, MCP_RX0IF | MCP_RX1IF); if(!setIdMode(can_mode)) return FAIL; result = setCtrlRegister(MCP_NORMAL); if(!result) Serial.print("Returning to Previous Mode Failure...rn"); return result; } I don't try to receive any frames now because initialization is not fully confirmed. Do you have any suggestions how to solve that? |
|
相关推荐
1个回答
|
|
你想读哪些寄存器,你得到什么值?设备必须连接到CAN收发器,总线必须终止,否则它永远无法正常启动(或退出配置模式)。您可能需要查看SPI总线上的数据以查看出错。将RPI SPI时序与ARDUINO进行比较。你可以在两个单元之间反转SPI时钟,或者使数据在错误的边缘上改变。汤姆
以上来自于百度翻译 以下为原文 Which registers are you trying to read and what values are you getting? The device has to be connected to a CAN Transceiver and the bus has to be terminated or it won't ever start up properly (or exit Config mode). You may need to look at the data on the SPI bus to see what is wrong. Compare the RPi SPI timing with the Arduino. You may have the SPI Clocks inverted between the two units, or have the data changing on the wrong edge. Tom |
|
|
|
只有小组成员才能发言,加入小组>>
5142 浏览 9 评论
1990 浏览 8 评论
1918 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3159 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
710浏览 1评论
598浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
481浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
610浏览 0评论
508浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 15:05 , Processed in 0.882114 second(s), Total 45, Slave 40 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号