CAN communications with PICS


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Smile thanks

    BIG WUMPUS,
    Thanks for the success story.

    I am doing the same basic thing, just need to be able to read a single can bus and decode data from it, then outputting data to LCD, leds, etc.
    Later this year I will be moving back into C programming with dsPIC's to talk to multiple CAN modules. This will take time of coarse, but for now I would really like to see If I can use PBP to just decode the data from the can.

    Can you provide any other places to begin researching, datasheets etc?
    thanks,
    Padawan-78

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Thumbs up

    I have written this code:

    Get it, look inside the datasheet of the CAN-Module and try to understand it.
    There is some trouble about timing, then I configure the filters and registers.
    In the main-program I poll the flags in order to see new data.


    ---
    Code:
    ;==========================================================================
    ;CAN-Interface steuern
    ;==========================================================================
    CAN_Init:
        CANCON=%10010000:Repeat:Until (CANSTAT & %11100000)=%10000000;Configuration Mode einschalten
        ECANCON=%01000000                               ;Mode 1
        RXFCON0=%00000000:RXFCON1=%00000000             ;alle 16 Filter:deaktiviert
        MSEL0=%11111111:MSEL1=%11111111:MSEL2=%11111111:MSEL3=%11111111;alle 16 Filter:no mask
        RXFBCON0=%00110010:RXFBCON1=%01010100:RXFBCON2=%01110110;Filter 0-5 -> B0-B5
        CIOCON=%00100000
        select case CAN_Mode
            case wMode_EuroTiger:                       ;Euro-Tiger
                BRGCON1=%01000001:BRGCON2=%10110001:BRGCON3=%00000101;BRP=0TQ,Sync=1TQ,Prop=2TQ,Phase1=7TQ,Phase2=6TQ,SJW=2TQ
                ;B0: EEC1 $0CF00400 Motordrehzahl
                RXF0SIDH=%01100111:RXF0SIDL=%10001000:RXF0EIDH=%00000100:RXF0EIDL=%00000000
                ;B1: EEC2 $0CF00300 Lastquotient
                RXF1SIDH=%01100111:RXF1SIDL=%10001000:RXF1EIDH=%00000011:RXF1EIDL=%00000000
                ;B2: Eng_Temp $18FEEE00 Temperaturen
                RXF2SIDH=%11000111:RXF2SIDL=%11101010:RXF2EIDH=%11101110:RXF2EIDL=%00000000
                ;B3: Inlet Conditions $18FEF600 Ladeduck
                RXF3SIDH=%11000111:RXF3SIDL=%11101010:RXF3EIDH=%11110110:RXF3EIDL=%00000000
                RXFCON0=%00001111                       ;Filter 0-3 aktiviert
        End select
    
    CAN_ON:
        tCAN_Sleep=wInput                               ;CAN-Transmitter einschalten
        CANCON=%01110000:Repeat:Until (CANSTAT & %11100000)=%01100000;Listen Mode einschalten
        CAN_Clear=%00111111:CAN_Restart=%00111111       ;alle Buffer leeren und alle Timer neu starten
        Return
    
    CAN_OFF:
        CANCON=%00110000:Repeat:Until (CANSTAT & %11100000)=%00100000;Disable Mode einschalten
        CAN_Sleep=true:tCAN_Sleep=wOutput:Return        ;CAN-Transmitter ausschalten
    ---
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

Similar Threads

  1. Multiple Pics accessing single EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd February 2008, 17:22
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. Dead PICs
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 15th August 2007, 13:12
  4. USB Pics, ICD2, pic basic pro
    By vacpress in forum USB
    Replies: 34
    Last Post: - 20th January 2007, 20:50
  5. PIC Basic Pro <-> HP-IL communications
    By swr999 in forum Serial
    Replies: 0
    Last Post: - 6th March 2006, 18:30

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts