title: STM32F4Discovery: CAN filter configuration
body: <p>I am using the <a href="http://www.st.com/en/evaluation-tools/stm32f4discovery.html" rel="nofollow noreferrer">STM32F4Discovery</a> kit to build a simple <a href="http://en.wikipedia.org/wiki/CAN_bus" rel="nofollow noreferrer">CAN</a> interface. I managed to configure it so I can transmit CAN messages, however, I am stuck at receiving them. As far so I know, to receive a CAN message, it has to pass acceptance filters. I would like to set the filter to accept all (standard, 2.0A) messages from ID 0x700 to 0x7FF. How do I do this?</p>
  
  <p>I've read the reference manual, but I have no idea how to actually configure the filtering.</p>
  
  <pre><code>void CAN_FilterConfiguration(void) {
      CAN_FilterInitTypeDef CAN_FilterInitStructure;
  
      /* CAN2 filter configuration */
      CAN_FilterInitStructure.CAN_FilterNumber = 1; // filter number = 1 (0&lt;=x&lt;=13)
      CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
      CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit;
      CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
      CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
      CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
      CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
      CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0; // FIFO = 0
      CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
      CAN_FilterInit(&amp;CAN_FilterInitStructure);
  }
  </code></pre>