文件名称:canf18xx8.h

  • 所属分类:
  • 其它
  • 资源属性:
  • [C/C++] [源码]
  • 上传时间:
  • 2009-05-25
  • 文件大小:
  • 10.43kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • lovelzs2008@126.com
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

、 先在microchip网站上找到00738.zip,这个包中有

can18xx8.h,can18xx8.c,将其复制到一个你要编写程度的子目录中,例如C:\testcan下,这个时候这个东东是不能直接用的。

2、 下载一个MPLAB 7.10,直接安装(要求直接下载)

3、 再下载一个PICC18 (HI-TECH的),要正版哦(支持正版,买不起的想其它办法吧)

4、在你的头文件上写上如下的样式:

#include "stdio.h"

#include "can18xx8.h"

#include "pic18fxx8.h"//可能是“pic.h”不太好包含,因此常会报错,直接包含克服之

5、然后设置好PICC和MPLAB,如果MPLAB上没有PICC18,则到PICC的网上下一个安装软件,可以直接运行安装就有了。

6、按照工程的基本要求把你的源代码、添加上两个库(不加也可以)

然后就可以写如下代码了:下面是一个完整版,可以直接使用microchip的库函数,本程序只是仿真调试过,未在多个芯片通信过,仍在制作中。

#include "stdio.h"

#include "can18xx8.h"

#include "pic18fxx8.h"

unsigned long NewMessage;

BYTE NewMessageData[8];

BYTE MessageData[8];

BYTE NewMessageLen;

enum CAN_RX_MSG_FLAGS NewMessageFlags=1;

BYTE RxFilterMatch;

void main()

{

//int a;

//int b;

CANInitialize(1, 5, 7, 6, 2, CAN_CONFIG_VALID_XTD_MSG);

while(1)

{

// Application specific logic here

// Check for CAN message

if ( CANIsRxReady() )

{

CANReceiveMessage(&NewMessage,NewMessageData,&NewMessageLen,&NewMessageFlags);

if ( NewMessageFlags & CAN_RX_OVERFLOW )

{

// Rx overflow occurred; handle it

}

if ( NewMessageFlags & CAN_RX_INVALID_MSG )

{

// Invalid message received; handle it

}

if ( NewMessageFlags & CAN_RX_XTD_fr a me )

{

// Extended Identifier received; handle it

}

else

{

// Standard Identifier received.

}

if ( NewMessageFlags & CAN_RX_RTR_fr a me )

{

// RTR fr a me received

}

else

{

// Regular fr a me received.

}

// Extract receiver filter match, if it is to be used

RxFilterMatch = NewMessageFlags & CAN_RX_FILTER_BITS;

}

// Process received message

// Transmit a message due to previously received message or

// due to application logic itself.

if ( CANIsTxReady() )

{

MessageData[0] = 0x01;

CANSendMessage( 0x02,MessageData,1,CAN_TX_PRIORITY_0

                             &CAN_TX_STD_fr a me &

                  CAN_TX_NO_RTR_fr a me);

}

// Other application specific logic

} // Do this forever

// End of program

}

以上均是参考文档并进行了修正,由于中间总是报错,为了大家让CAN更容易,谢谢大家!

(系统自动生成,下载前可以参看下载内容)

下载文件列表

压缩包 : dnd_notes_01.zip 列表
CAN18XX8.h
can18xx8.c

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org