 #include<can.h>



 void    Initial_CAN( void )   
  {   
          CAN1SetOperationMode(   CAN_IDLE_CON & CAN_MASTERCLOCK_0 &    
                                  CAN_REQ_OPERMODE_CONFIG ) ;   
     
          while ( C1CTRLbits.OPMODE <= 3 );   
     
              CAN1Initialize( CAN_SYNC_JUMP_WIDTH2 & CAN_BAUD_PRE_SCALE(24),   
                              CAN_WAKEUP_BY_FILTER_DIS &   
                              CAN_PHASE_SEG2_TQ(3) &   
                              CAN_PHASE_SEG1_TQ(3) &   
                              CAN_PROPAGATIONTIME_SEG_TQ(1) &    
                              CAN_SEG2_FREE_PROG & CAN_SAMPLE1TIME ) ;   
     		 	//filter_no - The filter (0, 1, 2, 3, 4 or 5) for which new filter values have to be configured.
				//CAN_FILTER_SID= filtre SID =  200	
				//Type of message to be received CAN_RX_EID_EN or CAN_RX_EID_DIS
				//Mask (SIDn/EIDn) Filter (SIDn/EIDn) Message (SIDn/EIDn) Accept or Reject bit n
				//0 x x Accept
				//1 0 0 Accept
				//1 0 1 Reject
				//1 1 0 Reject
				//1 1 1 Accept
              CAN1SetFilter ( (char) 0 , CAN_FILTER_SID( 200 ) & CAN_RX_EID_DIS ,   
                              CAN_FILTER_EID( 0x00 )) ; 
     		  	// mask_no - The mask (‘0’ or ‘1’) for which mask values have to be configured.
				// CAN_MASK_SID ( 0x00 ): 0x00 accepte toute adresse
				// Match/ignore message type specified in filter CAN_MATCH_FILTER_TYPE or CAN_IGNORE_FILTER_TYPE
              CAN1SetMask (   (char)0 , CAN_MASK_SID ( 0x00 ) & CAN_MATCH_FILTER_TYPE ,    
                              CAN_MASK_EID( 0x00) ) ;    
     
              CAN1SetTXMode( (char) 0 , CAN_TX_STOP_REQ & CAN_TX_PRIORITY_HIGH ) ;   
              CAN1SetRXMode( (char) 0 , CAN_RXFUL_CLEAR & CAN_BUF0_DBLBUFFER_EN ) ;   
     
              CAN1SetOperationMode(   CAN_IDLE_CON & CAN_CAPTURE_DIS & CAN_MASTERCLOCK_0 &   
                                      CAN_REQ_OPERMODE_NOR ) ;                               
  }  