i'm trying to bring auto generated code from STM32CUBEMX to Arduino,
what i need is internal DAC connected to Comparator (input- is DAC1 OUT1)
the error message isn't so much helpful, it looks like i'm missing some #include file to me, but can't figure out what's the one i need,
the complete error:
"
C:/Users/Administrator/AppData/Local/Arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Administrator\AppData\Local\Temp\arduino\sketches\A117D3EE0C52DC9A84814599FD54ED12\sketch\Test_stm32g431.ino.cpp.o: in function `setup':
Test_stm32g431.ino.cpp:(.text.setup+0x8a): undefined reference to `HAL_COMP_Init'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
"
Any help is appreciated, thank you a lot,
some source...
Code: Select all
#define HAL_DAC_MODULE_ENABLED //enable DAC
#include "stm32g4xx_hal_dac.h"
#define HAL_COMP_MODULE_ENABLED //enable Comparator
#include "stm32g4xx_hal_comp.h"
//none of the following helps...
//#include "stm32g4xx_ll_comp.h" //doesn't care
//#include "stm32g4xx_hal.h" //auto-included by Arduino??
//#include "stm32g4xx_hal_conf.h"
//#include "stm32g4xx_ll_system.h"
//#include "stm32g4xx_ll_utils.h"
DAC_HandleTypeDef hdac1; //DAC1
COMP_HandleTypeDef hcomp1; //comparator1
// the setup function runs once when you press reset or power the board
void setup() {
MX_DAC1_Init();
MX_COMP1_Init();
}
// the loop function runs over and over again forever
void loop() {
}
static void MX_COMP1_Init(void)
{
hcomp1.Instance = COMP1;
hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1;
hcomp1.Init.InputMinus = COMP_INPUT_MINUS_DAC1_CH1;
hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
hcomp1.Init.Hysteresis = COMP_HYSTERESIS_NONE;
hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_NONE;
//HERE IS THE PROBLEM!
if (HAL_COMP_Init(&hcomp1) != HAL_OK)
{
//Error_Handler();
}
}
/**
* @brief DAC1 Initialization Function
* @param None
* @retval None
*/
static void MX_DAC1_Init(void)
{
DAC_ChannelConfTypeDef sConfig = {0};
/** DAC Initialization
*/
hdac1.Instance = DAC1;
//THIS WORKS!
if (HAL_DAC_Init(&hdac1) != HAL_OK)
{
//Error_Handler();
}
/** DAC channel OUT1 config
*/
sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC;
sConfig.DAC_DMADoubleDataMode = DISABLE;
sConfig.DAC_SignedFormat = DISABLE;
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_INTERNAL;
sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
{
//Error_Handler();
}