Keil µVision5 - STM32F334R8 - Miising the appropriate header files

I'm starting to use Keil for my STM32 F334R8, and I recently downloaded the standard libraries package which provides examples, which is nice.The only more or less good tutorial I could find on starting developing on Keil using std lib was this one (in italian, that I don't speak). Following it (despite many differences between what I had and what I should have according to it), I managed to compile and run the GPIO example on my board. I mean, I didn't get any error, but in the end I don't have anything showing on the oscillo.

I tried to do the same with the DAC example, since this what I want, but here the example uses specific/basic/standard (whatever the name) libraries of the MCU, like stm32303c_eval.hI'm losing my mind on this. I don't think I'm asking too much, but.... I'm completely stuck.I just want something like stm32f334.h , you get the idea.I can't read anything from my output, i can't even blink a LED (I probably suck for this one, I know that).

My original objective was to output a sinewave from the DAC, but at this point, I'll take anything.

You can have fun with LED blinking without writing a single line of program, too, if you have a debugger which can manipulate the registers (Keil should be able to, I don't use it, neither I use an 'F3 but this should be the sam). Enable the relevant GPIO clock in RCC_AHBENR, set the appropriate pin to output in GPIOx_MODER and then toggle the appropriate bit in GPIOx_ODR.

I already downloaded the std lib from the link you both gave me. That part is ok.

I'm using NUCLEO-F334R8.

I'm focusing on the "DAC sigtnal generation" example.From the readme.txt:>"This example provides a short description of how to use the DAC peripheral to generate several signals using DMA controller.When the user presses the KEY push-button, DMA transfers the two selected waveforms to DAC.For each press on KEY button, 2 signals has been selected and monitored on the two dac channels: - Escalator waveform (Channel 1) and Sine waveForm (Channel 2). - Noise waveform (Channel 1) and Triangle waveform (Channel 2). "

So, admitting I use the USER button (the blue one on my board) to perform the actions of KEY button.

The code is rather long, so I won't paste all of it here, I'll keep focus on what I think is important.

First: you mentioned stm32f30x.h, and I think it is ok to use it as a base. It is indeed used in the example. The thing is, the main.c only include main.h . And in the main.h, I only have

#include "stm32f30x.h"

#include "stm32303c_eval.h"

so I'm pretty sure I'm supposed to use a more specific library too.

In the main.c, the DAC_Config() function looks okay imo:

staticvoidDAC_Config(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

/* DMA2 clock enable (to be used with DAC) */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);

/* DAC Periph clock enable */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

/* GPIOA clock enable */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

/* Configure PA.04 (DAC_OUT1) as analog */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);

}

It uses the right pins as output.

TIM_Config uses TIM2, so I guess I have to switch it into TIM6 because DAC1 and DAC2 run on TIM6 and TIM7.

After that, the main function configures the KEY button, and basically puts each type of output signal into an if.

Here is the code:You can note that there are too many channels here regarding of what I have on the F334R8 (Two DAC: DAC1 with 2 chan, DAC2 with 1 chan)

001.intmain(void)

002.{

003./*!< At this stage the microcontroller clock setting is already configured,

004.this is done through SystemInit() function which is called from startup

005.file (startup_stm32f30x.s) before to branch to application main.

006.To reconfigure the default setting of SystemInit() function, refer to

007.system_stm32f30x.c file

008.*/

009.

010./* Preconfiguration before using DAC----------------------------------------*/

Ok so, I cleaned the code as much as I could, and I modified it as it should work in my opinion (a manner to say I'm not completely lost anymore, just almost completely lost).

Here is the whole main.cI used [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/sawtooth&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=97]this example about a sawtooth signal to compare and improve the code.