STM32F107 DAC on chibios 2.6.4
Moderator: RoccoMarco
-
Augustarello
- Posts: 2
- Joined: Sat Sep 27, 2014 3:52 pm
STM32F107 DAC on chibios 2.6.4
Hallo!
I'd like to start the DAC driver on my Olimex STM32P107 board.
I've been working on Chibios branch 2.6.4, and this driver is not
there natively.
What would you suggest me, to wait for Chibi ver 3.0, or
instead to link it in my source tree myself?
In this case, I'd appreciate to receive the link for a stable
dac patch.
Bye,
A.
I'd like to start the DAC driver on my Olimex STM32P107 board.
I've been working on Chibios branch 2.6.4, and this driver is not
there natively.
What would you suggest me, to wait for Chibi ver 3.0, or
instead to link it in my source tree myself?
In this case, I'd appreciate to receive the link for a stable
dac patch.
Bye,
A.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F107 DAC on chibios 2.6.4
There is not such a thing, if you search in the forum you will find several contributed DAC drivers, none of them is final.
giovanni
giovanni
Re: STM32F107 DAC on chibios 2.6.4
Give this one a try, but you will have to tweak some options.
https://github.com/ChibiOS/ChibiOS-Drivers
There is a 2.6 branch.
https://github.com/ChibiOS/ChibiOS-Drivers
There is a 2.6 branch.
-
Augustarello
- Posts: 2
- Joined: Sat Sep 27, 2014 3:52 pm
Re: STM32F107 DAC on chibios 2.6.4
I've done, it seems to work!
I've just tried to generate dac voltage outputs
using "dacConvert(&DACD1,dac_value)".
For sake of completeness, in my main.c i've made
the following modifications:
+ #include "drivers.h"
+ static const DACConfig daccfg = {
DAC_DHRM_12BIT_RIGHT, /* data holding register mode */
0 /* DAC CR flags */
};
+ dacStart(&DACD1, &daccfg);
+ dacConvert(&DACD1,dac_value);
In order to compile this driver, the instructions available
in file "readme.md" are not enough, i've had to include
drivers_conf.h, as visible below and finally to
modify my original halconf.h adding the following lines:
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC TRUE
+#endif
This is my drivers_conf.h
I've just tried to generate dac voltage outputs
using "dacConvert(&DACD1,dac_value)".
For sake of completeness, in my main.c i've made
the following modifications:
+ #include "drivers.h"
+ static const DACConfig daccfg = {
DAC_DHRM_12BIT_RIGHT, /* data holding register mode */
0 /* DAC CR flags */
};
+ dacStart(&DACD1, &daccfg);
+ dacConvert(&DACD1,dac_value);
In order to compile this driver, the instructions available
in file "readme.md" are not enough, i've had to include
drivers_conf.h, as visible below and finally to
modify my original halconf.h adding the following lines:
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC TRUE
+#endif
This is my drivers_conf.h
Code: Select all
/*
* drivers_conf.h
*
* Created on: 14/gen/2015
* Author: gluca
*/
#ifndef DRIVERS_CONF_H_
#define DRIVERS_CONF_H_
/**
* @brief Enables the Drivers.
*/
#if !defined(DRIVER_USE_DAC) || defined(__DOXYGEN__)
#define DRIVER_USE_DAC TRUE
#endif
#if !defined(DRIVER_USE_IWDG) || defined(__DOXYGEN__)
#define DRIVER_USE_IWDG FALSE
#endif
#if !defined(DRIVER_USE_TIMCAP) || defined(__DOXYGEN__)
#define DRIVER_USE_TIMCAP FALSE
#endif
#if !defined(DRIVER_USE_IUART) || defined(__DOXYGEN__)
//COMMENT OUT BY CC++
//#define DRIVER_USE_IUART TRUE
//COMMENT OUT BY CC--
#define DRIVER_USE_IUART FALSE
#endif
#if !defined(DRIVER_USE_EICU) || defined(__DOXYGEN__)
#define DRIVER_USE_EICU FALSE
#endif
#if !defined(DRIVER_USE_EEPROM) || defined(__DOXYGEN__)
#define DRIVER_USE_EEPROM FALSE
#endif
/*
* DAC driver system settings.
*/
#define STM32_DAC_USE_CHN1 TRUE
//add by cc+
#define STM32_HAS_DAC_CHN1 TRUE
//add by cc-
#define STM32_DAC_CHN1_IRQ_PRIORITY 10
#define STM32_DAC_CHN1_DMA_PRIORITY 2
#define STM32_DAC_DMA_ERROR_HOOK(dacp) chSysHalt()
#define STM32_DAC_CHN1_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
//removed by cc++
//#define STM32_DAC_USE_CHN2 FALSE
//removed by cc--
//add by cc++
#define STM32_DAC_USE_CHN2 FALSE
//add by cc--
#define STM32_DAC_CHN2_IRQ_PRIORITY 10
#define STM32_DAC_CHN2_DMA_PRIORITY 2
#define STM32_DAC_DMA_ERROR_HOOK(dacp) chSysHalt()
#define STM32_DAC_CHN2_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
/*
* TIMCAP driver system settings.
*/
#define STM32_TIMCAP_USE_TIM1 FALSE
#define STM32_TIMCAP_USE_TIM2 FALSE
#define STM32_TIMCAP_USE_TIM3 FALSE
#define STM32_TIMCAP_TIM1_IRQ_PRIORITY 2
#define STM32_TIMCAP_TIM2_IRQ_PRIORITY 2
#define STM32_TIMCAP_TIM3_IRQ_PRIORITY 2
/*
* IUART driver system settings.
*/
#define STM32_IUART_USE_USART1 FALSE
#define STM32_IUART_USE_USART2 FALSE
#define STM32_IUART_USART1_IRQ_PRIORITY 3
#define STM32_IUART_USART2_IRQ_PRIORITY 3
/*
* Extended ICU driver system settings.
*/
#define STM32_EICU_USE_TIM1 FALSE
#define STM32_EICU_USE_TIM2 FALSE
#define STM32_EICU_USE_TIM3 FALSE
#define STM32_EICU_USE_TIM4 FALSE
#define STM32_EICU_USE_TIM5 FALSE
#define STM32_EICU_USE_TIM8 FALSE
#define STM32_EICU_USE_TIM9 FALSE
#define STM32_EICU_USE_TIM12 FALSE
#define STM32_EICU_TIM1_IRQ_PRIORITY 3
#define STM32_EICU_TIM2_IRQ_PRIORITY 3
#define STM32_EICU_TIM3_IRQ_PRIORITY 3
#define STM32_EICU_TIM4_IRQ_PRIORITY 3
#define STM32_EICU_TIM5_IRQ_PRIORITY 3
#define STM32_EICU_TIM8_IRQ_PRIORITY 3
#define STM32_EICU_TIM9_IRQ_PRIORITY 3
#define STM32_EICU_TIM12_IRQ_PRIORITY 3
/*
* EEPROM driver system settings.
*/
#define EEPROM_DRV_USE_25XX FALSE
#define EEPROM_DRV_USE_24XX FALSE
#define EEPROM_DRV_TABLE_SIZE 2
#endif /* DRIVERS_CONF_H_ */
Re: STM32F107 DAC on chibios 2.6.4
Hi,
I get the following error when linking:
Linking build/ch.elf
build/obj/dac_lld.o: In function `dac_lld_init':
C:\ChibiStudio\workspace26\STM32F4xx-DAC-Test/../../ChibiOS-Drivers/stm32/dac_lld.c:138: undefined reference to `_stm32_dma_streams'
Any ideas?
Thanks!
Nils
I get the following error when linking:
Linking build/ch.elf
build/obj/dac_lld.o: In function `dac_lld_init':
C:\ChibiStudio\workspace26\STM32F4xx-DAC-Test/../../ChibiOS-Drivers/stm32/dac_lld.c:138: undefined reference to `_stm32_dma_streams'
Any ideas?
Thanks!
Nils
Re: STM32F107 DAC on chibios 2.6.4
Hmm, strange, the error changed... not sure what I have changed in the meantime...
Linking build/ch.elf
`chThdExit' referenced in section `.text._port_thread_start.4322' of C:\Users\OSSENB~1.FB1\AppData\Local\Temp\cc8fCAza.ltrans0.ltrans.o: defined in discarded section `.text' of build/obj/chthreads.o (symbol from plugin)
C:\Users\OSSENB~1.FB1\AppData\Local\Temp\cc8fCAza.ltrans0.ltrans.o: In function `_trace_init':
C:\ChibiStudio\workspace26\STM32F4xx-DAC-Test/../../chibios/os/kernel/src/chdebug.c:231: undefined reference to `_stm32_dma_streams'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
I have no idea what's going on...
Linking build/ch.elf
`chThdExit' referenced in section `.text._port_thread_start.4322' of C:\Users\OSSENB~1.FB1\AppData\Local\Temp\cc8fCAza.ltrans0.ltrans.o: defined in discarded section `.text' of build/obj/chthreads.o (symbol from plugin)
C:\Users\OSSENB~1.FB1\AppData\Local\Temp\cc8fCAza.ltrans0.ltrans.o: In function `_trace_init':
C:\ChibiStudio\workspace26\STM32F4xx-DAC-Test/../../chibios/os/kernel/src/chdebug.c:231: undefined reference to `_stm32_dma_streams'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
I have no idea what's going on...
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F107 DAC on chibios 2.6.4
Are you mixing files from 2.6 and 3.0? make sure that all the configuration files and the makefile come from the version you are actually using.
Giovanni
Giovanni
Re: STM32F107 DAC on chibios 2.6.4
Thanks for your comments. Error "undefined reference to `_stm32_dma_streams'" dissapeared after enabling SPI as Mobyfab recommended. I think I have messed up something else... I will try to restart from scratch and see if I can get it running...
Re: STM32F107 DAC on chibios 2.6.4
Ok, a step further... DAC works with dacConvert(&DACD1,dac_value);
@Mobifab: Do you have an example for a simple sinewave -or whatever- DMA application? Tried this http://forum.chibios.org/phpbb/viewtopic.php?f=16&t=2274&sid=922760ebe0bec88e6f3bf751c592bbfa#p18358 one without success (even when stripped down to one channel)? Thank you in advance!
Cheers
Nils
@Mobifab: Do you have an example for a simple sinewave -or whatever- DMA application? Tried this http://forum.chibios.org/phpbb/viewtopic.php?f=16&t=2274&sid=922760ebe0bec88e6f3bf751c592bbfa#p18358 one without success (even when stripped down to one channel)? Thank you in advance!
Cheers
Nils