ADC on STM32F4Discovery

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

ADC on STM32F4Discovery

Post 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!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ADC on STM32F4Discovery

Post by Giovanni »

hI,

Is the ADC enabled in halconf.h?

Giovanni
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: ADC on STM32F4Discovery

Post 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!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ADC on STM32F4Discovery

Post 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
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: ADC on STM32F4Discovery

Post 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.. :)
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: ADC on STM32F4Discovery

Post by Ramazzukk »

Now its running fine, thank you very much for your advice!
Post Reply