Page 1 of 1

ADC on STM32F4Discovery

Posted: Sun Jan 06, 2013 2:36 pm
by Ramazzukk
Hi there,

First: Thank you for that outstanding nice OS Giovanni!

I tried to get the Example-Code from http://www.chibios.org/dokuwiki/doku.ph ... overy:code to work.

But I am not able to compile. Error Codes are (amongst others):

main.c:59:19: error: unknown type name 'ADCDriver'
main.c:59:36: error: unknown type name 'adcsample_t'
main.c:71:1: error: unknown type name 'adcsample_t'
main.c:79:1: error: unknown type name 'ADCConversionGroup'

Includeded are:

#include "ch.h"
#include "hal.h"
#include "shell.h"
#include "chprintf.h"
#include <ff.h>
#include <string.h>
#include "mad.h"


I am pretty sure that this is some header or configuration problem, but can't find the solution. How do I proceed to find the solution to the problem? Thanks very much for any assist beforehand!

Re: ADC on STM32F4Discovery

Posted: Sun Jan 06, 2013 4:07 pm
by Giovanni
hI,

Is the ADC enabled in halconf.h?

Giovanni

Re: ADC on STM32F4Discovery

Posted: Sun Jan 06, 2013 4:36 pm
by Ramazzukk
It was not :oops: , thank you!

It is much better, but still not working:

#error "STM32_ADCCLK outside acceptable range (STM32_ADCCLK_MIN...STM32_ADCCLK_MAX)"

Do I have to set the frequency somewhere?

Thanks again for your help!

Re: ADC on STM32F4Discovery

Posted: Sun Jan 06, 2013 5:21 pm
by Giovanni
Hi,

It is quite complex, the frequency is calculated from all the clock settings in mcuconf.h, it is strange because the defaults should be OK.

Make sure to take the file mcuconf.h from a project using the ADC for your same MCU, try ./testhal/STM32F4xx/ADC.

Giovanni

Re: ADC on STM32F4Discovery

Posted: Sun Jan 06, 2013 5:46 pm
by Ramazzukk
Hello Giovanni,

Thanks for your very fast reply. Again you were spot on:

#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4

was ADC_CCR_ADCPRE_DIV2 instead of ADC_CCR_ADCPRE_DIV4.

It compiles now, I have to test it further.. :)

Re: ADC on STM32F4Discovery

Posted: Tue Jan 08, 2013 8:57 pm
by Ramazzukk
Now its running fine, thank you very much for your advice!