stm32g491cet6 ADC interruption and Hal_Delay not working - ide

I have a number of issues with stm32g491cet6.
When using the ADC interrupt, it remains in an infinite loop. When using the HAL_Delay () function, an infinite loop also results.
The code is simple and runs on the application board with stm32f103 but not on stm32g491cet6 (two separate projects of course).
The PWM work good.
Any ideas?
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();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_ADC_Start_IT (&hadc1);
HAL_Delay(100);
}
/* USER CODE END 3 */
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_4);
}

Related

HAL SPI Transmit Receive function not working correctly?

I am trying to create a data aqcuisition system for a load cell, using the INA128P amplifier, the LTC1296 12-bit ADC and a NUCLEO f401re with code on STM32CubeIDE. I have been having problems trying to make the SPI to work properly, since according to my logic analyser the input word to configure the ADC is not transmitted correctly and all the bits received are high. Below are my code and information from the LTC1296 datasheet
LTC1296 SPI information
/* USER CODE BEGIN Header */
/**
******************************************************************************
* #file : main.c
* #brief : Main program body
******************************************************************************
* #attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart2;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_SPI1_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* #brief The application entry point.
* #retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
char uart_buf[100];
char boofer[100];
uint8_t ADC_buf[3];
//input word is 00010100 11000000
uint8_t input_word[3] = {0x14, 0xC0, 0x00};
int uart_buf_len;
int length;
uint16_t testdata[100];
uint8_t i = 0;
uint16_t sample;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_SPI1_Init();
/* USER CODE BEGIN 2 */
// CS pin should default high
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
uart_buf_len = sprintf(uart_buf, "SPI test\r\n");
HAL_UART_Transmit(&huart2, (uint8_t *)uart_buf, uart_buf_len, 100);
HAL_Delay(1000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi1, input_word, ADC_buf, 3, 10);
//while(&hspi1.State == HAL_SPI_STATE_BUSY);
//HAL_SPI_Receive(&hspi1, ADC_buf, 3, 100);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
sample = (((uint16_t)ADC_buf[1] & (0b1111)) << 8) | (uint16_t)ADC_buf[2];
testdata[i] = sample;
//uart_buf_len = sprintf(uart_buf, testdata[i]);
//HAL_UART_Transmit_IT(&huart2, (uint16_t *)uart_buf, 2);
length =sprintf(boofer,"%d ",testdata[i]) + 1;
HAL_UART_Transmit(&huart2, &boofer, length, 100);
i++;
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

STM32F469I-disco SPI-CAN shield

STM32F469I-disco :
https://os.mbed.com/platforms/ST-Discovery-F469NI/
https://www.st.com/en/evaluation-tools/32f469idiscovery.html
STM32F302R8 : https://os.mbed.com/platforms/ST-Nucleo-F302R8/
CAN shield : https://www.amazon.it/AptoFun-Receiver-Protocol-Controller-Development/dp/B082B9JKH1
Hello everyone, I’m still inexperienced and I have to use the CAN with the F469I screen, but I was unable to operate the built-in CAN1 and CAN2 (honestly, I still don’t understand why CAN2 doesn’t work.). So I decided to use a CAN shield (SPI-CAN) but I can’t figure out what I’m doing wrong.
In particular, I use this library : https://github.com/eziya/STM32_SPI_MCP2515
This is the main.c
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"
#include "app_touchgfx.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "../Components/otm8009a/otm8009a.h"
#include "stm32469i_discovery_sdram.h"
#include "stm32469i_discovery_qspi.h"
#include "CANSPI.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* DISPLAY */
#define LCD_ORIENTATION_LANDSCAPE 0x01
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
CRC_HandleTypeDef hcrc;
DMA2D_HandleTypeDef hdma2d;
DSI_HandleTypeDef hdsi;
I2C_HandleTypeDef hi2c1;
LTDC_HandleTypeDef hltdc;
QSPI_HandleTypeDef hqspi;
SPI_HandleTypeDef hspi2;
SDRAM_HandleTypeDef hsdram1;
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for TouchGFXTask */
osThreadId_t TouchGFXTaskHandle;
const osThreadAttr_t TouchGFXTask_attributes = {
.name = "TouchGFXTask",
.stack_size = 4096 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* USER CODE BEGIN PV */
HAL_StatusTypeDef status = HAL_ERROR;
int value = 0,
err = 0,
data = 150,
delay = 0,
tick = 0;
uCAN_MSG txMessage, rxMessage;
bool statusTx = false,
statusRx = false;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_CRC_Init(void);
static void MX_DMA2D_Init(void);
static void MX_DSIHOST_DSI_Init(void);
static void MX_FMC_Init(void);
static void MX_LTDC_Init(void);
static void MX_QUADSPI_Init(void);
static void MX_I2C1_Init(void);
static void MX_SPI2_Init(void);
void StartDefaultTask(void *argument);
extern void TouchGFX_Task(void *argument);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* #brief The application entry point.
* #retval int
*/
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();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CRC_Init();
MX_DMA2D_Init();
MX_DSIHOST_DSI_Init();
MX_FMC_Init();
MX_LTDC_Init();
MX_QUADSPI_Init();
MX_I2C1_Init();
MX_SPI2_Init();
MX_TouchGFX_Init();
/* USER CODE BEGIN 2 */
if (!CANSPI_Initialize()) {
Error_Handler();
}
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize();
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */
/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */
/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */
/* Create the thread(s) */
/* creation of defaultTask */
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
/* creation of TouchGFXTask */
TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_EVENTS */
/* add events, ... */
/* USER CODE END RTOS_EVENTS */
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
[...]
/**
* #brief SPI2 Initialization Function
* #param None
* #retval None
*/
static void MX_SPI2_Init(void)
{
/* USER CODE BEGIN SPI2_Init 0 */
/* USER CODE END SPI2_Init 0 */
/* USER CODE BEGIN SPI2_Init 1 */
/* USER CODE END SPI2_Init 1 */
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
/* USER CODE END SPI2_Init 2 */
}
[...]
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* #brief Function implementing the defaultTask thread.
* #param argument: Not used
* #retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
statusRx = CANSPI_Receive(&rxMessage);
if(statusRx)
{
txMessage.frame.idType = rxMessage.frame.idType;
txMessage.frame.id = rxMessage.frame.id;
txMessage.frame.dlc = rxMessage.frame.dlc;
txMessage.frame.data0++;
txMessage.frame.data1 = rxMessage.frame.data1;
txMessage.frame.data2 = rxMessage.frame.data2;
txMessage.frame.data3 = rxMessage.frame.data3;
txMessage.frame.data4 = rxMessage.frame.data4;
txMessage.frame.data5 = rxMessage.frame.data5;
txMessage.frame.data6 = rxMessage.frame.data6;
txMessage.frame.data7 = rxMessage.frame.data7;
value++;
statusTx = CANSPI_Transmit(&txMessage);
}
txMessage.frame.idType = dSTANDARD_CAN_MSG_ID_2_0B;
txMessage.frame.id = 0x0A;
txMessage.frame.dlc = 8;
txMessage.frame.data0 = 0;
txMessage.frame.data1 = 1;
txMessage.frame.data2 = 2;
txMessage.frame.data3 = 3;
txMessage.frame.data4 = 4;
txMessage.frame.data5 = 5;
txMessage.frame.data6 = 6;
txMessage.frame.data7 = 7;
statusTx = CANSPI_Transmit(&txMessage);
osDelay(100);
}
[...]
Together with the display, I use an F302R8 as the second CAN node. This node is sure that it works and that it is configured well (already tested) but if you need poss or post the code.
I tried with many combinations, even changing SPI of the F469 or jumpers but it doesn’t work anyway.
Could it be Baudrate’s problem? I am now using a 1Mbit/s baudrate, I used datasheet formulas (MCP2515) whereas the CAN shield is 8Mhz.
/*
tq = 2 * (brp(0) + 1) / 8000000 = 0.25us
tbit = (SYNC_SEG(1 fixed) + PROP_SEG + PS1 + PS2)
tbit = 1tq + 5tq + 6tq + 4tq = 16tq
16tq = 4us = 1000kbps
*/
If you have examples of SPI-CAN (or only CAN) used with the F469I-disc they would be very useful. I am still very inexperienced with the STM.
Here also the STM ioc configuration :

transmission and reception problems with stm32f103c8 with nrf24 library

i am developing my project in a stm32f103c8 (bluepill) with Keil and CubeMX, i want to use a nrf24l01 transmitter and for this i looked for a tutorial which is exactly what i want to do. the problem is that when i do it i notice that the radio transceiver does not transmit or receive, i have seen on the internet that some people have problems with this card that i am using, just me this is failing me using this library. I leave a link to a video that shows the same steps that I made in addition to the library. precisely the function nrf24_write is the one that is not working. I hope you can help me because I've been trying to understand why it does not work for several days.
link video:
https://www.youtube.com/watch?v=O2dg2Eo7vo8
link library:
https://github.com/MYaqoobEmbedded/STM32-Tutorials/tree/master/Tutorial%2024%20-%20NRF24L01%20Radio%20Transceiver
main code:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "MY_NRF24.h"
#include "stdio.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint64_t TxpipeAddrs = 0x324e6f6465;
char myTxData[32]; //= "Hello World!";
char AckPayload[32];
/* USER CODE END 0 */
/**
* #brief The application entry point.
* #retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
myTxData[0]= 0;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
NRF24_begin(GPIOB, GPIO_PIN_8, GPIO_PIN_9, hspi1);
nrf24_DebugUART_Init(huart1);
//**** TRANSMIT - ACK ****//
NRF24_setPALevel(RF_PWR_HIGH);
NRF24_openWritingPipe(TxpipeAddrs);
NRF24_setAutoAck(true);
NRF24_setChannel(52);
NRF24_setPayloadSize(32);
NRF24_setDataRate(RF24_2MBPS);
NRF24_enableDynamicPayloads();
NRF24_enableAckPayload();
NRF24_stopListening();
HAL_Delay(1000);
printRadioSettings();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
if(NRF24_write(myTxData, 32))
{
NRF24_read(AckPayload, 32);
HAL_UART_Transmit(&huart1, (uint8_t *)"Transmitted Successfully\r\n", strlen("Transmitted Successfully\r\n"), 10);
char myDataack[80];
sprintf(myDataack, "AckPayload: %s \r\n", AckPayload);
HAL_UART_Transmit(&huart1, (uint8_t *)myDataack, strlen(myDataack), 10);
}else{
HAL_UART_Transmit(&huart1, (uint8_t *)"Transmitted Failed\r\n", strlen("Transmitted Failed\r\n"), 10);}
myTxData[0]= myTxData[0] + 1;
HAL_Delay(1000);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

Stm32 ADC - DMA transfer use only half buffer

I'm sampling an analog audio signal with STM32F767ZIT6 processor, I'm trying to use DMA double buffer combined with ADC, in debug mode all seems works well until the half CpltCallback interrupt, when it's fired I can see half of buffer full, but when the full CpltCallback is called the buffer still half full, half empty, and the old samples are overwritten, this is doesn't depend from buffer dimension, I've tried with 10 or 2048 samples and the result is always the same.
In debug mode I see that half CpltCallback is fired two times before full CpltCallback call.
Here is the little program:
Main:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "adc.h"
#include "dma.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "defines.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
volatile uint32_t adc_samples[2*ADC_BUFF_DIM];
volatile uint32_t adc_buff[2][ADC_BUFF_DIM];
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* #brief The application entry point.
* #retval int
*/
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();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/**
* #brief System Clock Configuration
* #retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 96;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Activate the Over-Drive mode
*/
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* #brief This function is executed in case of error occurrence.
* #retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
/* USER CODE END Error_Handler_Debug */
}
#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,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
ADC conversions start:
void EXTI15_10_IRQHandler(void)
{
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
if((GPIOC -> IDR & BUTTON_PIN) || (GPIOB -> IDR & ANLG_IN_CTRL_PIN)) //RISING EDGE
{
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) &adc_buff, 2*ADC_BUFF_DIM);
GPIOB -> ODR |= GREEN_LED_PIN;
}
else //FALLING EDGE
{
HAL_ADC_Stop_DMA(&hadc1);
GPIOB -> ODR &= ~GREEN_LED_PIN;
}
/* USER CODE END EXTI15_10_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
/* USER CODE END EXTI15_10_IRQn 1 */
}
DMA call back:
void DMA2_Stream0_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream0_IRQn 0 */
/* USER CODE END DMA2_Stream0_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc1);
/* USER CODE BEGIN DMA2_Stream0_IRQn 1 */
/* USER CODE END DMA2_Stream0_IRQn 1 */
}
/* USER CODE BEGIN 1 */
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
{
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
}
Disable D and I Cache and then try.

How to properly receive a msg via CAN with STM32F105

This is my first time programming a microcontroller and I was wondering how to receive a msg via CAN using the interrupt. I initialized my micro, STM32F105, so that only 0x0106 and 0x010A IDs are allowed.
This is the main section:
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_ADC1_Init();
MX_CAN1_Init();
MX_IWDG_Init();
MX_RTC_Init();
MX_SPI1_Init();
MX_TIM1_Init();
MX_TIM2_Init();
MX_UART4_Init();
MX_UART5_Init();
/* USER CODE BEGIN 2 */
/* Initialize CAN Filter */
CAN_FilterConfTypeDef sFilterConfig;
sFilterConfig.FilterNumber=0;
sFilterConfig.FilterMode=CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterScale=CAN_FILTERSCALE_16BIT;
sFilterConfig.FilterIdHigh=0x10A<<5;
sFilterConfig.FilterIdLow=0x106<<5;
sFilterConfig.FilterMaskIdHigh=0x7FF<<5;
sFilterConfig.FilterMaskIdLow=0x7FF<<5;
sFilterConfig.FilterFIFOAssignment=0;
sFilterConfig.FilterActivation=ENABLE;
sFilterConfig.BankNumber=0;
HAL_CAN_ConfigFilter(&hcan1,&sFilterConfig);
if (HAL_CAN_ConfigFilter(&hcan1,&sFilterConfig) != HAL_OK)
{
Error_Handler();
}
HAL_CAN_Receive_IT(&hcan1,CAN_FIFO0);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
//some code here
}
/* USER CODE END 3 */
This is the CAN intialization section:
/* CAN1 init function */
static void MX_CAN1_Init(void)
{
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 4;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SJW = CAN_SJW_1TQ;
hcan1.Init.BS1 = CAN_BS1_6TQ;
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;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
Error_Handler();
}
}
And this is the interrupt section:
void CAN1_RX0_IRQHandler(void)
{
/* USER CODE BEGIN CAN1_RX0_IRQn 0 */
/* USER CODE END CAN1_RX0_IRQn 0 */
HAL_CAN_IRQHandler(&hcan1);
/* USER CODE BEGIN CAN1_RX0_IRQn 1 */
// other code here
}
Basically, what happens is that when I test my board it seems like the interrupt routine is never executed.. Do you know where's the problem?