Basic CAN driver to turn on/off accessory wire

Code to flash to microcontrollers for interfacing into the CAN Bus.
Post Reply
User avatar
codekey
CAN? Tin or aluminum?
Posts: 35
Joined: 2005 Jul 26 05:14
Location: Irvine, CA

Basic CAN driver to turn on/off accessory wire

Post by codekey »

Code: Select all


// Using Microchips C18 Compiler
// Using PIC18F2480
// Using TJA1054 Transceiver
// 4 MHZ Crystal

//******************** main.c

#include  <p18cxxx.h>
#include "vw.h"
#include "can.c" // can.c and can.h is generated from Micrchips Maestro program - CAN Driver (Interrupt Driven)

#pragma config OSC = XT
#pragma config LVP = OFF
#pragma config PWRT = ON
#pragma config BOR = BOHW
#pragma config BORV = 42
#pragma config MCLRE = ON
#pragma config XINST = OFF
#pragma config CP0 = ON
#pragma config CP1 = ON
#pragma config WDT = OFF
#pragma config DEBUG = OFF

#define ACC_Output PORTAbits.RA1// accessory wire output
#define wake PORTAbits.RA2// TJA1054
#define stb_mode0 PORTAbits.RA4// TJA1054
#define en PORTAbits.RA5// TJA1054

#define true 1
#define false 0
#define firstByte 0
#define secondByte 1

#define AccessoryBit_Chrysler 1
#define IgnitionBit_Chrysler 2
#define KeyInBit 0

#define testbit(var,bit) ((var) & (1l<<(bit)))// tests bits in message

unsigned char checkMessage;

#pragma interrupt HighISR save=section(".tmpdata")
void HighISR(void)
{
	CANISR();
}

#pragma code highVector=0x08
void HighVector (void)
{
    _asm goto HighISR _endasm
}
#pragma code /* return to default code section */

void main()			//Main entry
{
	struct CANMessage RX_Message, TX_Message;	//Declare one message structure for transmission and one for reception
	char i, I_Have_Something_To_Send = 0;		
		
	ADCON1 = 0x0f; // set A/D to digital inputs
	TRISA  = 0x00; // port will vary depeding on your design
	TRISB = 0b00111001;
	TRISC = 0xff;
	PORTA = 0;
	PORTB = 0;
	PORTC = 0x00;
	
		// 83.33k baud rate
		BAUD_RATE_PRESC = 1;//do one up more than bit calculator's number
		SJW_TIME = 1;
		PROP_TIME = 7;
		PH_SEG_1 = 8;
		PH_SEG_2 = 8;
		SAMPLES = 1;

		RXFILT0 = 0x00; // BCM
		RXFILT1 = 0; 
		RXFILT2 = 0;
		RXFILT3 = 0x3a0;// chrysler
		RXFILT4 = 0;
		RXFILT5 = 0;
		
		CHRYSLER_SWC_ID = RXFILT3;		
		BCM_ID	= RXFILT0;

		MY_IDENT = 0x00;

	
//**************************************************
//				CAN configuration
//**************************************************
	CAN_CONFIG_1 = BAUD_RATE_PRESC-1|(SJW_TIME-1<<6);
	if(SAMPLES == 1)
	{
		CAN_CONFIG_2 = 0x80|(PH_SEG_1-1<<3)|(PROP_TIME-1);
	}
	else
	if(SAMPLES == 3)
	{
		CAN_CONFIG_2 = 0xC0|(PH_SEG_1-1<<3)|(PROP_TIME-1);
	}
	CAN_CONFIG_3 = PH_SEG_2-1;
//**************************************************
//				end CAN configuration
//**************************************************
	
	CANInit();			//Initialize CAN module
		
	INTCONbits.GIE = 1;			//Enable interrupts
	INTCONbits.PEIE = 1;
	
	T0CON = 0xC4; // timer0 on, 1:32 prescaler, 8 bit counter
	INTCONbits.INT0IE = 1;
	INTCON2bits.INTEDG0 = 0;
	
	wake = 1; // set up TJA1054 CAN transceiver for normal mode
	en = 1;
	stb_mode0 = 1;
		
	while(1)
	{
		if(CANRXMessageIsPending())	//Check if there is an unread CAN message
		{
			TMR0Count1 = 0;
			RX_Message = CANGet();	//Get the message
			if(RX_Message.Remote == 1 && RX_Message.Address == MY_ADDRESS_IDENTIFIER)
			{						//Check if it was a Remote Transmission Request message and My Identifier
				I_Have_Something_To_Send = 1;	//Set the send flag
			}
			else
			{
				checkMessage = 1;
			}
		}
		
		if(I_Have_Something_To_Send)	
		{
			TX_Message.Address = MY_ADDRESS_IDENTIFIER;		//Set the address to My identifier
#ifdef MY_ADDRESS_IS_STANDARD
			TX_Message.Ext = 0;								//If the identifier is standard, clear the Ext flag
#else
			TX_Message.Ext = 1;								//If the identifier is extended, set the Ext flag
#endif
			TX_Message.NoOfBytes = RX_Message.NoOfBytes;	//Set number of bytes to send
			for(i=0; i<TX_Message.NoOfBytes; i++)			//Fill the Data bytes
			{
				TX_Message.Data[i] = i;
			}
			TX_Message.Remote = 0;							//clear the remote flag
			TX_Message.Priority = 0;						//Internal CAN module priority 0-> least priority, 3-> most priority
			CANPut(TX_Message);								//Put the message in the FIFO
			I_Have_Something_To_Send = 0;
		}
		
		if(checkMessage)
		{
			checkMessage = 0;
				if(RX_Message.Address == BCM_ID)
				{
					if(testbit(RX_Message.Data[firstByte],AccessoryBit_Chrysler) || testbit(RX_Message.Data[firstByte],IgnitionBit_Chrysler) )
					{
						ACC_Output = 1;// turn accessory wire on
					}
					if(!testbit(RX_Message.Data[firstByte],AccessoryBit_Chrysler)  && !testbit(RX_Message.Data[firstByte],IgnitionBit_Chrysler))//
					{
						ACC_Output = 0;// turn accessory wire off
					}
				}
			}
		}
	}	
}




//******************** main.h


#if defined (_18F2480)
#define CANCON CANCON_0
#define CANSTAT CANSTAT_0
#endif

unsigned char BAUD_RATE_PRESC, PROP_TIME, PH_SEG_1, PH_SEG_2, SJW_TIME, SAMPLES;
unsigned int CAN_CONFIG_1, CAN_CONFIG_2, CAN_CONFIG_3;
unsigned int RXMASK0, RXMASK1, RXFILT0, RXFILT1, RXFILT2, RXFILT3, RXFILT4, RXFILT5;
unsigned int MY_IDENT;
unsigned int VW_SWC_ID, PORSCHE_SWC_ID, MERCEDES_SWC_ID, CHRYSLER_SWC_ID, BCM_ID;


//******************** candef.h


/****************************************************
*       This file was created by                    *
*       Microchip Application Maestro               *
*       and holds the set-up parameters             *
*       specified when the code was generated.      *
*       The user is advised not to make any         *
*       changes to this file                        *
****************************************************/

//100k baud rate
//Dual wire can setup
//#define BAUD_RATE_PRESC 1//do one up more than bit calculator's number
//#define PROP_TIME 3
//#define PH_SEG_1 8
//#define PH_SEG_2 8
//#define SJW_TIME 1
//
//#define SAMPLES 1
//// do not modify here
//#define CAN_CONFIG_1 BAUD_RATE_PRESC-1|(SJW_TIME-1<<6)
//#if SAMPLES == 1
//#define CAN_CONFIG_2 0x80|(PH_SEG_1-1<<3)|(PROP_TIME-1)
//#elif SAMPLES == 3
//#define CAN_CONFIG_2 0xC0|(PH_SEG_1-1<<3)|(PROP_TIME-1)
//#else
//#error "Number of samples is out of range"
//#endif
//#define CAN_CONFIG_3 PH_SEG_2-1
//end do not modify
//****** ID filters and masks

// masks, put '1' so byte must match same column, put '0' for don't care.

//#define RXMASK0 0xffffffff // associated with RXFILT0 and RXFILT1
//#define RXMASK1 0xffffffff // associated with RXFILT2, 3, 4, and 5
//
//#define RXFILT0 0x5c1
#define ST_FILTER_0

//#define RXFILT1 0x271
#define ST_FILTER_1

//#define RXFILT2 0x5c3
#define ST_FILTER_2

//#define RXFILT3 0
#define ST_FILTER_3

//#define RXFILT4 0
#define ST_FILTER_4

//#define RXFILT5 0
#define ST_FILTER_5
//**** end ID filters and masks

//#define LPBACK
//#define MY_IDENT 0x00
#define STD_IDENT // comment out for extended ID
#define RX_BUFFER 4
#define TX_BUFFER 4
//#define CAN_INT_LOW
//#define CAN_ERROR_HANDLER_ENABLE


User avatar
linuxkidd
Site Admin
Posts: 365
Joined: 2005 Jul 22 15:48
Location: Anywhere, USA
Contact:

Post by linuxkidd »

Thanks for the Code!!

Hey, can you post an introduction in the 'Introductions' forum?
If you can read this, the light is still red.
User avatar
codekey
CAN? Tin or aluminum?
Posts: 35
Joined: 2005 Jul 26 05:14
Location: Irvine, CA

New code

Post by codekey »

The previous code had some glitches when i was testing the Auxiliary input i am working on. The old code used interrupts and the new one below uses polling. Of course it has all the major code removed for the aux input, but it gives you an idea how to filter on a specific ID and byte(s) and set an output.

The ECANPoll.c, ECANPoll.h and ECANPoll.def files are produced from Microchip's Maestro program.

I lost the original schematic and pcb layout so i just whip up a basic schematic and pcb which is posted on my earthlink site. You can change/add what ever you want.


main program

Code: Select all

/*
		Product name: CANHACK
		Description: Chrysler Interface.
		Compiler: MPLAB C18 ver 2.44
		Programmer: codekey

*/

#include "ecanpoll.c"
#include <delays.h>

#define ACC_Output PORTAbits.RA1

/*   TJA1054 defines */
#define WAKE PORTAbits.RA2
#define STB_MODE0 PORTAbits.RA4
#define EN PORTAbits.RA5
#define ERR PORTBbits.RB0

#define TESTBIT(var,bit) ((var) & (1l<<(bit)))// tests bits in message

/* Configuration Bits */
#pragma config OSC = XT
#pragma config LVP = OFF
#pragma config PWRT = ON
#pragma config BOR = BOHW
#pragma config MCLRE = ON
#pragma config XINST = OFF
#pragma config BORV = 42
#pragma config CP0 = ON
#pragma config CP1 = ON

#if defined(MPLAB_ICD)
#pragma config WDT = OFF
#pragma config DEBUG = ON
#else
#pragma config WDT = ON // be sure that this is on or else pic will draw to much current in sleep!!!!!
#pragma config DEBUG = OFF
#endif

#define BYTE1 0
#define BYTE2 1

/* Define Global Variables */
unsigned char SOH_MessageFlag;
unsigned char TJA_SleepFlag, CheckMessageFlag, RAP_Flag, ACC_Flag;

unsigned long TMR0Count, TMR0Count1;

unsigned int BCM_ID, RAP_ID;

unsigned long ID_ADDRESS, MyID;
unsigned char RAP_Flag;
unsigned char i;

BYTE RX_Data[8];
BYTE TX_Data[8];
BYTE dataLen;
ECAN_RX_MSG_FLAGS flags;

void RunTimeInitialization(void);
void Send_SOH(void);

#pragma interrupt HighISR save=section(".tmpdata")
void HighISR(void)
{               
	ClrWdt();
	if(INTCONbits.INT0IE && INTCONbits.INT0IF)// RB0 interrupt
	{      
		INTCONbits.INT0IF = 0;	// clear interrupt flag	
		if(!PORTBbits.CANRX)// Rx I/O from TJA1054
		{
			// CAN bus is busy, so turn on CAN transceiver to normal mode
			STB_MODE0 = 1;			
			EN = 1;
		}
	}       

	if(INTCONbits.TMR0IE && INTCONbits.TMR0IF)// TMR0 interrupt
	{       
		INTCONbits.TMR0IF = 0;// clear interrupt flag
		++TMR0Count;
		++TMR0Count1;
		PORTCbits.RC1 = 0; // debug output, delete for production
		if(!ACC_Output && TMR0Count1 > 488)// 5 seconds, if no data on CAN bus, put tranceiver and pic to sleep
		{
			TMR0Count1 = 0;
			TJA_SleepFlag = 1;	
		}
	}
	       
	if(TMR0Count > 60)// 12 = 0.1 second, 48 = 0.4 seconds, 60 = 0.5 seconds, 122 = 1 second, 244 = 2 seconds, 488 = 4 seconds
	{       
		TMR0Count = 0;// reset to zero
		if(ACC_Output)
		{
//			SOH_MessageFlag = 1;// send SOH message every 500ms	
//			Send_SOH();
		}
	}       
}               
                
#pragma code highVector=0x08
void HighVector (void)
{               
    _asm goto HighISR _endasm
}               
#pragma code /* return to default code section */

void Send_SOH(void)
{               
	MyID = 0x00; 
	TX_Data[0] = 0x00;	
	TX_Data[1] = 0x00;
	TX_Data[2] = 0x00;
	TX_Data[3] = 0x00;
	TX_Data[4] = 0x00;
	TX_Data[5] = 0x00;
	TX_Data[6] = 0x00;
	TX_Data[7] = 0x00;
	dataLen = 8;
	while(!ECANSendMessage(MyID, TX_Data, dataLen, flags) );			
}

//**************************************************
//				Main Function
//**************************************************
void main(void)
{
//**************************************************
//				set ports and A/D
//**************************************************
   	ADCON1 = 0x0f; // set A/D to digital inputs
	TRISA  = 0;
	TRISB = 0b00011001;
	TRISC = 0;
	PORTA = 0;
	PORTB = 0;
	PORTC = 0;

//**************************************************
//				Set CAN filters and masks
//**************************************************	
	BCM_ID	= ECAN_RXF0_VAL;
	RAP_ID	= ECAN_RXF1_VAL;
	
//**************************************************
//				Set Interrupts
//**************************************************   	
	INTCONbits.GIE = 1;			//enable interrupts
	INTCONbits.GIEL = 1;
	INTCONbits.PEIE = 1;
	INTCON2bits.INTEDG0 = 0;
	INTCON2bits.TMR0IP = 1;
		        
	T0CON = 0xC4; // timer0 on, 1:32 prescaler, 8 bit counter
	INTCONbits.TMR0IE = 1;
	INTCONbits.INT0IE = 1;
//**************************************************
//				Set TJA1054 for nomal mode
//**************************************************
    WAKE = 1; // set up TJA1054 CAN transceiver for normal mode
	EN = 1; 
	STB_MODE0 = 1;

//**************************************************
//				Initialize CAN
//**************************************************

	Delay10KTCYx(100); // delay for 2 seconds so interface does not lock up
	Delay10KTCYx(100);
	flags = ECAN_TX_PRIORITY_1 || ECAN_TX_STD_FRAME || ECAN_TX_NO_RTR_FRAME;
    ECANInitialize();

//**************************************************
//				Main routine
//**************************************************
    for(;;)
    {
	    while( !ECANReceiveMessage(&ID_ADDRESS, RX_Data, &dataLen, &flags) )
	    {
		    if(TJA_SleepFlag) // put TJA1054 and PIC to sleep if no activity for 4 seconds
			{
				TJA_SleepFlag = 0;	
				ACC_Output = 0; // turn off ACC_Output
				EN = 1;// put TJA1054 to sleep mode
				STB_MODE0 = 0;	
				Sleep();// put PIC to sleep
				Nop();
			}
		}
		
		if(ID_ADDRESS == BCM_ID || ID_ADDRESS == RAP_ID)
		{
      		if(ID_ADDRESS == BCM_ID)
        	{
	        	if(RX_Data[0] == 0x33  || RX_Data[0] == 0x63 || RX_Data[0] == 0x85 || RX_Data[0] == 0x87)
        		{
	        		ACC_Flag = 1;
	        	}
	        	else
	        	ACC_Flag = 0;
		    }
		    else
		    
		    if(ID_ADDRESS == RAP_ID)
		    {
			    if(TESTBIT(RX_Data[1],1))
			    {
				    RAP_Flag = 1;
				}
				else
				RAP_Flag = 0;
		    }
		    
        	if(RAP_Flag || ACC_Flag)
        	{
	        	ACC_Output = 1;// turn on accessory wire and LED
	        }
	        else
	        {
	        	ACC_Output = 0;
	        }
        }
    } 
}

ECANPoll.def

Code: Select all

/*###########################################################################
*This file is generated by Microchip Application Maestro
*DO NOT MODIFY MANUALLY
*###########################################################################*/
#ifndef  _ECANPOLL_DEF
#define _ECANPOLL_DEF
// 
//
// ECAN Routine Mode:
// Possible values are ECAN_LIB_MODE_FIXED, ECAN_LIB_MODE_RUN_TIME
//   Use ECAN_LIB_MODE_FIXED if run-time selection of mode is not required.
//   Use ECAN_LIB_MODE_RUN_TIME if run-time selection is required.
#define ECAN_LIB_MODE_VAL ECAN_LIB_MODE_RUN_TIME
//
// ECAN Functional Mode to be used in ECANInitialize().
// Possible values are ECAN_MODE_0, ECAN_MODE_1, ECAN_MODE_2
#define ECAN_FUNC_MODE_VAL ECAN_MODE_1
//
// Mode to leave ECAN after ECANInit. 
// Possible values are ECAN_INIT_NORMAL, ECAN_INIT_CONFIGURATION, ECAN_INIT_LOOPBACK, ECAN_INIT_DISABLE
#define ECAN_INIT_MODE ECAN_INIT_NORMAL
//
// SJW value - Value must be between 1-4 inclusive.
#define ECAN_SJW_VAL 1
//
// BRP value - Value must be between 1-64 inclusive.
#define ECAN_BRP_VAL 1
//
// PHSEG1 value - Value must be between 1-8 inclusive.
#define ECAN_PHSEG1_VAL 8
//
// PHSEG2 value - Value must be between 1-8 inclusive.
#define ECAN_PHSEG2_VAL 8
//
// PROPSEG value - Value must be between 1-8 inclusive.
#define ECAN_PROPSEG_VAL 7
//
// Use freely progrmable PHSEG2 or calculated value.
#define ECAN_PHSEG2_MODE_VAL ECAN_PHSEG2_MODE_PROGRAMMABLE
//
// Bus Sample Mode
#define ECAN_BUS_SAMPLE_MODE_VAL ECAN_BUS_SAMPLE_MODE_ONCE
//
// Wakeup Mode
#define ECAN_WAKEUP_MODE_VAL ECAN_WAKEUP_MODE_ENABLE
//
// Filter Mode
#define ECAN_FILTER_MODE_VAL ECAN_FILTER_MODE_DISABLE
//
// CANTX1 Drive Mode
#define ECAN_TXDRIVE_MODE_VAL ECAN_TXDRIVE_MODE_VDD
//
// CANTX2 pin mode
#define ECAN_TX2_MODE_VAL ECAN_TX2_MODE_DISABLE
//
// CANTX2 Source
#define ECAN_TX2_SOURCE_VAL ECAN_TX2_SOURCE_COMP
//
// CAN Capture Mode
#define ECAN_CAPTURE_MODE_VAL ECAN_CAPTURE_MODE_DISABLE
//
// RXB0 Recieve Mode
#define ECAN_RXB0_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// RXB0 Double Buffer Mode
#define ECAN_RXB0_DBL_BUFFER_MODE_VAL ECAN_DBL_BUFFER_MODE_DISABLE
//
// RXB1 Recieve Mode
#define ECAN_RXB1_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B0 Tx/Rx mode Mode
#define ECAN_B0_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B0 Recieve Mode
#define ECAN_B0_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B0 Auto RTR Mode
#define ECAN_B0_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// B1 Tx/Rx mode Mode
#define ECAN_B1_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B1 Recieve Mode
#define ECAN_B1_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B1 Auto RTR Mode
#define ECAN_B1_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// B2 Tx/Rx mode Mode
#define ECAN_B2_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B2 Recieve Mode
#define ECAN_B2_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B2 Auto RTR Mode
#define ECAN_B2_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// B3 Tx/Rx mode Mode
#define ECAN_B3_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B3 Recieve Mode
#define ECAN_B3_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B3 Auto RTR Mode
#define ECAN_B3_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// B4 Tx/Rx mode Mode
#define ECAN_B4_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B4 Recieve Mode
#define ECAN_B4_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B4 Auto RTR Mode
#define ECAN_B4_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// B5 Tx/Rx mode Mode
#define ECAN_B5_TXRX_MODE_VAL ECAN_BUFFER_TX
//
// B5 Recieve Mode
#define ECAN_B5_MODE_VAL ECAN_RECEIVE_ALL_VALID
//
// B5 Auto RTR Mode
#define ECAN_B5_AUTORTR_MODE ECAN_AUTORTR_MODE_DISABLE
//
// RXF0 Filter Enable/Disable
#define ECAN_RXF0_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF0 Filter Type
#define ECAN_RXF0_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF0 Value
#define ECAN_RXF0_VAL 0x000L
//
// RXF0 Buffer Link
#define ECAN_RXF0_BUFFER_VAL RXB0
//
// RXF0 Mask Link
#define ECAN_RXF0_MASK_VAL ECAN_RXM0
//
// RXF1 Filter Enable/Disable
#define ECAN_RXF1_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF1 Filter Type
#define ECAN_RXF1_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF1 Value
#define ECAN_RXF1_VAL 0x006L
//
// RXF1 Buffer Link
#define ECAN_RXF1_BUFFER_VAL RXB0
//
// RXF1 Mask Link
#define ECAN_RXF1_MASK_VAL ECAN_RXM0
//
// RXF2 Filter Enable/Disable
#define ECAN_RXF2_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF2 Filter Type
#define ECAN_RXF2_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF2 Value
#define ECAN_RXF2_VAL 0x0L
//
// RXF2 Buffer Link
#define ECAN_RXF2_BUFFER_VAL RXB1
//
// RXF2 Mask Link
#define ECAN_RXF2_MASK_VAL ECAN_RXM1
//
// RXF3 Filter Enable/Disable
#define ECAN_RXF3_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF3 Filter Type
#define ECAN_RXF3_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF3 Value
#define ECAN_RXF3_VAL 0x0L
//
// RXF3 Buffer Link
#define ECAN_RXF3_BUFFER_VAL RXB1
//
// RXF3 Mask Link
#define ECAN_RXF3_MASK_VAL ECAN_RXM1
//
// RXF4 Filter Enable/Disable
#define ECAN_RXF4_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF4 Filter Type
#define ECAN_RXF4_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF4 Value
#define ECAN_RXF4_VAL 0x0L
//
// RXF4 Buffer Link
#define ECAN_RXF4_BUFFER_VAL RXB1
//
// RXF4 Mask Link
#define ECAN_RXF4_MASK_VAL ECAN_RXM1
//
// RXF5 Filter Enable/Disable
#define ECAN_RXF5_MODE_VAL ECAN_RXFn_ENABLE
//
// RXF5 Filter Type
#define ECAN_RXF5_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF5 Value
#define ECAN_RXF5_VAL 0x0L
//
// RXF5 Buffer Link
#define ECAN_RXF5_BUFFER_VAL RXB1
//
// RXF5 Mask Link
#define ECAN_RXF5_MASK_VAL ECAN_RXM1
//
// RXF6 Filter Enable/Disable
#define ECAN_RXF6_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF6 Filter Type
#define ECAN_RXF6_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF6 Value
#define ECAN_RXF6_VAL 0x0L
//
// RXF6 Buffer Link
#define ECAN_RXF6_BUFFER_VAL RXB0
//
// RXF6 Mask Link
#define ECAN_RXF6_MASK_VAL ECAN_RXM0
//
// RXF7 Filter Enable/Disable
#define ECAN_RXF7_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF7 Filter Type
#define ECAN_RXF7_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF7 Value
#define ECAN_RXF7_VAL 0x0L
//
// RXF7 Buffer Link
#define ECAN_RXF7_BUFFER_VAL RXB0
//
// RXF7 Mask Link
#define ECAN_RXF7_MASK_VAL ECAN_RXM0
//
// RXF8 Filter Enable/Disable
#define ECAN_RXF8_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF8 Filter Type
#define ECAN_RXF8_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF8 Value
#define ECAN_RXF8_VAL 0x0L
//
// RXF8 Buffer Link
#define ECAN_RXF8_BUFFER_VAL RXB0
//
// RXF8 Mask Link
#define ECAN_RXF8_MASK_VAL ECAN_RXM0
//
// RXF9 Filter Enable/Disable
#define ECAN_RXF9_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF9 Filter Type
#define ECAN_RXF9_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF9 Value
#define ECAN_RXF9_VAL 0x0L
//
// RXF9 Buffer Link
#define ECAN_RXF9_BUFFER_VAL RXB0
//
// RXF9 Mask Link
#define ECAN_RXF9_MASK_VAL ECAN_RXM0
//
// RXF10 Filter Enable/Disable
#define ECAN_RXF10_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF10 Filter Type
#define ECAN_RXF10_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF10 Value
#define ECAN_RXF10_VAL 0x0L
//
// RXF10 Buffer Link
#define ECAN_RXF10_BUFFER_VAL RXB0
//
// RXF10 Mask Link
#define ECAN_RXF10_MASK_VAL ECAN_RXM0
//
// RXF11 Filter Enable/Disable
#define ECAN_RXF11_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF11 Filter Type
#define ECAN_RXF11_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF11 Value
#define ECAN_RXF11_VAL 0x0L
//
// RXF11 Buffer Link
#define ECAN_RXF11_BUFFER_VAL RXB0
//
// RXF11 Mask Link
#define ECAN_RXF11_MASK_VAL ECAN_RXM0
//
// RXF12 Filter Enable/Disable
#define ECAN_RXF12_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF12 Filter Type
#define ECAN_RXF12_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF12 Value
#define ECAN_RXF12_VAL 0x0L
//
// RXF12 Buffer Link
#define ECAN_RXF12_BUFFER_VAL RXB0
//
// RXF12 Mask Link
#define ECAN_RXF12_MASK_VAL ECAN_RXM0
//
// RXF13 Filter Enable/Disable
#define ECAN_RXF13_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF13 Filter Type
#define ECAN_RXF13_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF13 Value
#define ECAN_RXF13_VAL 0x0L
//
// RXF13 Buffer Link
#define ECAN_RXF13_BUFFER_VAL RXB0
//
// RXF13 Mask Link
#define ECAN_RXF13_MASK_VAL ECAN_RXM0
//
// RXF14 Filter Enable/Disable
#define ECAN_RXF14_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF14 Filter Type
#define ECAN_RXF14_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF14 Value
#define ECAN_RXF14_VAL 0x0L
//
// RXF14 Buffer Link
#define ECAN_RXF14_BUFFER_VAL RXB0
//
// RXF14 Mask Link
#define ECAN_RXF14_MASK_VAL ECAN_RXM0
//
// RXF15 Filter Enable/Disable
#define ECAN_RXF15_MODE_VAL ECAN_RXFn_DISABLE
//
// RXF15 Filter Type
#define ECAN_RXF15_MSG_TYPE_VAL ECAN_MSG_STD
//
// RXF15 Value
#define ECAN_RXF15_VAL 0x0L
//
// RXF15 Buffer Link
#define ECAN_RXF15_BUFFER_VAL RXB0
//
// RXF15 Mask Link
#define ECAN_RXF15_MASK_VAL ECAN_RXM0
//
// RXM0 Type
#define ECAN_RXM0_MSG_TYPE ECAN_MSG_STD
//
// RXM0 Value
#define ECAN_RXM0_VAL 0xffffffffL
//
// RXM1 Type
#define ECAN_RXM1_MSG_TYPE ECAN_MSG_STD
//
// RXM1 Value
#define ECAN_RXM1_VAL 0xffffffffL
#endif
asher
How the heck did I end up here?
Posts: 1
Joined: 2013 Dec 10 02:53

Re: Basic CAN driver to turn on/off accessory wire

Post by asher »

hello
how i can get file.hex that i can use it on pic18f2480
PAC
What's hacking?
Posts: 19
Joined: 2005 Jul 27 01:31

Re: Basic CAN driver to turn on/off accessory wire

Post by PAC »

The hex file is proprietary to PAC. You have to write your own code.
Karl Yamashita
Rosen Electronics
Sr. Electrical Engineer
(note: I no longer work for PAC since December 2013)
Post Reply