急,关于使用mc9s12xdp512的SPI1通过MCP2515扩展CAN问题
- UID
- 813472
|
急,关于使用mc9s12xdp512的SPI1通过MCP2515扩展CAN问题
void SPI1_Init(void) //spi initial
{
SPI1CR1 = 4;
(void)SPI1SR; /* Read the status register */
(void)SPI1DR; /* Read the device register */
SPI1BR = 68; /* Set the baud rate register */
SPI1CR2 = 0; /* Set control register 2 */
SPI1CR1 = 84; /设置上升沿发送,下降沿接收.高位先发送*/
}
为什么接收到的mcp2515信号不对,读MCP2515寄存器,返回的数据也有问题,我用示波器看返回的信号,怎么和正弦波差不多,信号夹在里面...
后来我加个上拉电阻,是查看到高低电平信号了,可收到的数据也不对....
哪位有用过的大侠帮忙找下原因吧,为什么收到的信号不对。。。万分感谢 |
|
|
|
|
|
- UID
- 815443
- 性别
- 女
|
帮你顶下哦~~ |
辛苦,并幸福快乐着~~
http://www.ceetop.com/3c-ggv |
|
|
|
|
|
- UID
- 813472
|
我把SPI1CR1 = 84; 改为SPI1CR1 = 80;
84时;Sampling of data occurs at even edges (2,4,6,...,16) of the SCK clock.
80时,Sampling of data occurs at odd edges (1,3,5,...,15) of the SCK clock.
我对上面两句话不是很理解....谁解释下
现在是可以接收到,只是MCP2515输出的数据波形很不稳定...
咋加个上拉电平可以稳定,但好象是不用加的吧,我还没查接收到的数据对不对,只是测试与别的CAN可以收发了,哪位大侠解释一下.... |
|
|
|
|
|
- UID
- 809074
|
|
|
|
|
|
- UID
- 519949
- 性别
- 男
|
|
|
|
|
|
- UID
- 813472
|
好多天没来看了,SPI扩展CAN部分早已调通了,SPI1CR1 = 80; 才对
其它的按照MCP2515的资料接收发送就可以了 |
|
|
|
|
|