• PicŪ Basic


  • CAN commands

    A library module for use with Library Manager by JohnGB. This module has been written by Bobby Garrett (RGV250 on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    This library provides a set of functions to configure and access the Microchip CAN module in selected PICŪ.

    The library was designed around the CAN module in 18F448/458, it also works in legacy mode(0) on newer PICŪ with ECAN modules (tested on 18F4680).

    Syntax

    The library consists of 10 commands of which most need to be used so I will be creating example code.

    • CAN Overview


    !!!Operators
    • CANInitialise - Initialises the CAN module
    • CANSetOperationMode - Sets the operating mode for the CAN module
    • CANSetMask - Used in conjunction with CANSetFilter
    • CANSetFilter - See CANSetMask
    • CANSetNodeID - Sets the node ID, must be unique to the network
    • CANSetMsgID - Used in conjunction with the Node ID to form the Identifier
    • CANSetBaudRate - Set all the parameters for communication
    • CANSendMessage - Formats Node/Msg ID and DATA for the CAN module to transmit
    • CANReceiveMessage - Returns with the Node/Msg ID and DATA for the current message
    • CANAbortAll - Cancels ALL pending messages

    Examples
    • All code examples will be designed for 20Mhz xtal. - Do not use ceramic resonators.
    • The examples will be tested on 18F448 & 18F4680
    • Please note, the examples have only been tested on the latest beta release 3.3.4.8. Support will only be given for that and later versions. The library will run on versions prior to this.
    • CAN connection sketch (hand drawn)
    • Simple periodic example
    • Simple event demo
    • Multiple messages demo
    • Expanding the network demo
    • Masks and Filters demo Future - Under construction
    • Changing the speed - Xtal & BUS - Under construction

    !!!Notes: Only Standard Identifiers have been catered for, if there is a demand for Extended Identifiers I will look into it. The Identifier consists of 5 bits for the NodeID which gives a max of 32 nodes and 6 bits are used for the MsgID giving a max of 64 messages.

    Remote transmit requests "RTR" have not been tested.

    I would like to thank JohnGB for his assistance in getting all this into a workable library and with some of the code.



    Download module

    Download ALL the library files including the CAN modules HERE
  • Recent Activity

    teo-16018

    Microsoft security essentials blues

    Thread Starter: shantanu@india

    Hi, A strange thing happened just now.My Windows 7 Micrsoft Sercurity Essentials suddenly gave a warning that prplus.exe(Compiler) is a potential...

    teo Today, 19:23 Go to last post
    pic-ignorant-1162

    Proton Runtime Error

    Thread Starter: Paulcc

    I have proton running well on my laptop, but after installing it on my desktop, I get the following runtime error: "Runtime Error 217 at 000709FC" I...

    pic-ignorant Yesterday, 22:11 Go to last post
    David Barker-251

    UMC bootloader 18F46K22

    Thread Starter: shunt010

    Hi all. I am trying to build a UMC bootloader file for the 18F46K22, and it doesn't appear to work. It returns (in the error log) Error ...

    David Barker Today, 11:20 Go to last post
    barak-1433

    SPI mssp

    Thread Starter: picprotonguy

    Just ordered Digital to Analog IC MCP4822 with SPI interface and immediately opened proton manual. I'm very disappointed, it looks like Proton...

    barak Today, 16:06 Go to last post