title: STM32F429 is not receiving the CAN Message
body: <p>I am using STM32F429 Microcontroller and need to implement CAN Bus Communication between CAN2 and PCAN View.I am able to transmit the message from CAN2 but I am not able to receive any message.I am using TJA1041A CAN transreceiver in the microcontroller.The Problem is that during debugging my CAN bus are properly initalized but it doesn't go to the receive command although I have initalized FIFO0.Herewith I am attching the program for further reference.I have used STM32 HAL Cube for programming.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>/**
    ******************************************************************************
    * File Name          : main.c
    * Date               : 05/12/2014 09:43:55
    * Description        : Main program body
    ******************************************************************************
    *
    * COPYRIGHT(c) 2014 STMicroelectronics
    *
    * Redistribution and use in source and binary forms, with or without modification,
    * are permitted provided that the following conditions are met:
    *   1. Redistributions of source code must retain the above copyright notice,
    *      this list of conditions and the following disclaimer.
    *   2. Redistributions in binary form must reproduce the above copyright notice,
    *      this list of conditions and the following disclaimer in the documentation
    *      and/or other materials provided with the distribution.
    *   3. Neither the name of STMicroelectronics nor the names of its contributors
    *      may be used to endorse or promote products derived from this software
    *      without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    ******************************************************************************
    */
  
  /* Includes ------------------------------------------------------------------*/
  #include "stm32f4xx_hal.h"
  
  /* USER CODE BEGIN Includes */
  
  /* USER CODE END Includes */
  
  /* Private variables ---------------------------------------------------------*/
  CAN_HandleTypeDef hcan1;
  CAN_HandleTypeDef hcan2;
  
  /* USER CODE BEGIN PV */
  
  /* USER CODE END PV */
  
  /* Private function prototypes -----------------------------------------------*/
  void SystemClock_Config(void);
  static void MX_GPIO_Init(void);
  static void MX_CAN1_Init(void);
  static void MX_CAN2_Init(void);
  
  /* USER CODE BEGIN PFP */
  
  /* USER CODE END PFP */
  
  /* USER CODE BEGIN 0 */
  
  /* USER CODE END 0 */
  
  int main(void)
  {
  
    /* USER CODE BEGIN 1 */
  
    /* USER CODE END 1 */
  
    /* MCU Configuration----------------------------------------------------------*/
  
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();
  
    /* Configure the system clock */
    SystemClock_Config();
  
    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    MX_CAN1_Init();
    MX_CAN2_Init();
  
    /* USER CODE BEGIN 2 */
   __GPIOD_CLK_ENABLE();
  
   GPIO_InitTypeDef  GPIO_Initpins;
   
   GPIO_Initpins.Mode = GPIO_MODE_OUTPUT_PP ;
   GPIO_Initpins.Pin = GPIO_PIN_5|GPIO_PIN_7;
   GPIO_Initpins.Pull = GPIO_NOPULL  ;
   HAL_GPIO_Init(GPIOD, &amp;GPIO_Initpins);
   
   HAL_GPIO_WritePin(GPIOD, GPIO_PIN_5|GPIO_PIN_7, GPIO_PIN_SET);
    /* USER CODE END 2 */
  
    /* USER CODE BEGIN 3 */
    /* Infinite loop */
    CanTxMsgTypeDef TxMess;
    
    TxMess.StdId = 0x123;
    TxMess.DLC = 0x0;
    TxMess.Data[0] = 0x12;
    TxMess.IDE = 0;
    TxMess.RTR = 0;
   
      hcan2.pTxMsg = &amp;TxMess;
      HAL_CAN_Transmit(&amp;hcan2,50);
      HAL_Delay(500);
    
   /* USER CODE END 2 */
  
    
  
   CanRxMsgTypeDef RMess;
   
    RMess.FIFONumber = CAN_FIFO1;
    RMess.FMI = 14;
    RMess.StdId = 0x541;
    RMess.DLC = 0;
    RMess.RTR = 0;
    RMess.IDE = CAN_ID_STD;
    hcan2.pRxMsg = &amp;RMess;
    
    HAL_CAN_Receive_IT(&amp;hcan2,CAN_FIFO1);
    /* USER CODE BEGIN 3 */
    /* Infinite loop */
    while (1)
    {
    
     HAL_CAN_Receive(&amp;hcan2,CAN_FIFO1,0);
     
    }
    /* USER CODE END 3 */
  
  }
  
  /** System Clock Configuration
  */
  void SystemClock_Config(void)
  {
  
    RCC_OscInitTypeDef RCC_OscInitStruct;
    RCC_ClkInitTypeDef RCC_ClkInitStruct;
  
    __PWR_CLK_ENABLE();
  
    __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
  
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
    HAL_RCC_OscConfig(&amp;RCC_OscInitStruct);
  
    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    HAL_RCC_ClockConfig(&amp;RCC_ClkInitStruct, FLASH_LATENCY_0);
  
  }
  
  /* CAN1 init function */
  void MX_CAN1_Init(void)
  {
  
    hcan1.Instance = CAN1;
    hcan1.Init.Prescaler = 16;
    hcan1.Init.Mode = CAN_MODE_NORMAL;
    hcan1.Init.SJW = CAN_SJW_1TQ;
    hcan1.Init.BS1 = CAN_BS1_1TQ;
    hcan1.Init.BS2 = CAN_BS2_1TQ;
    hcan1.Init.TTCM = DISABLE;
    hcan1.Init.ABOM = DISABLE;
    hcan1.Init.AWUM = DISABLE;
    hcan1.Init.NART = DISABLE;
    hcan1.Init.RFLM = DISABLE;
    hcan1.Init.TXFP = DISABLE;
    HAL_CAN_Init(&amp;hcan1);
  
    /*CAN_FilterConfTypeDef CAN_Filters;
    
       CAN_Filters.BankNumber = 0;
       CAN_Filters.FilterActivation = ENABLE;
       CAN_Filters.FilterFIFOAssignment = CAN_FILTER_FIFO0 ;
       CAN_Filters.FilterIdHigh = 0x00;
       CAN_Filters.FilterIdLow = 0x00;
       CAN_Filters.FilterMaskIdHigh = 0x00;
       CAN_Filters.FilterMaskIdLow = 0x00;
       CAN_Filters.FilterMode = CAN_FILTERMODE_IDMASK;
       CAN_Filters.FilterNumber = 0;
       CAN_Filters.FilterScale = CAN_FILTERSCALE_32BIT;
     
       HAL_CAN_ConfigFilter(&amp;hcan1, &amp;CAN_Filters);*/ 
  
  }
  
  /* CAN2 init function */
  void MX_CAN2_Init(void)
  {
    hcan2.Instance = CAN2;
    hcan2.Init.Prescaler = 2;
    hcan2.Init.Mode = CAN_MODE_NORMAL;
    hcan2.Init.SJW = CAN_SJW_1TQ;
    hcan2.Init.BS1 = CAN_BS1_5TQ;
    hcan2.Init.BS2 = CAN_BS2_2TQ;
    hcan2.Init.TTCM = DISABLE;
    hcan2.Init.ABOM = DISABLE;
    hcan2.Init.AWUM = DISABLE;
    hcan2.Init.NART = DISABLE;
    hcan2.Init.RFLM = DISABLE;
    hcan2.Init.TXFP = DISABLE;
    HAL_CAN_Init(&amp;hcan2);
    
   }
  
  /** Configure pins as 
          * Analog 
          * Input 
          * Output
          * EVENT_OUT
          * EXTI
  */
  void MX_GPIO_Init(void)
  {
  
    /* GPIO Ports Clock Enable */
    __GPIOH_CLK_ENABLE();
    __GPIOB_CLK_ENABLE();
    __GPIOA_CLK_ENABLE();
  
  }
  
  /* USER CODE BEGIN 4 */
  
  /* USER CODE END 4 */
  
  #ifdef USE_FULL_ASSERT
  
  /**
     * @brief Reports the name of the source file and the source line number
     * where the assert_param error has occurred.
     * @param file: pointer to the source file name
     * @param line: assert_param error line source number
     * @retval None
     */
  void assert_failed(uint8_t* file, uint32_t line)
  {
    /* USER CODE BEGIN 6 */
    /* User can add his own implementation to report the file name and line number,
      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
    /* USER CODE END 6 */
  
  }
  
  #endif
  
  /**
    * @}
    */ 
  
  /**
    * @}
  */ 
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks </p>