I've been reading a lot online to figure what is not working in my code, but it seems like the ADC conversion in my code never starts and I'm getting really desperate... No matter what I do, the EOC Flag always remain to 0 and I am currently out of ideas. Making the ADC work should be simple, but for some reason, I am completly unable to make it work.

I'd be very grateful if someone could show me where my mistakes seems to be. I am using the STM32L100CR-Discovery.

/* Standard includes. */
#include "stm32l1xx.h"
#include "stm32l1xx_rcc.h"
#include "stm32l1xx_gpio.h"
#include "stm32l1xx_exti.h"
#include "stm32l1xx_syscfg.h"
#include "stm32l1xx_spi.h"
#include "stdio.h"
#include "misc.h"

{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

}

{
printf("%d", statut);

return valeur;

}

int main(void)
{

while(1)
{
}
}


stm32 stm

• It's probably worth starting with some example code, and then perhaps gradually migrating that towards your need. If the chip is not on an eval board, also make sure you connected all the power and ground pairs, not just some of them. – Chris Stratton Feb 24 '19 at 18:30
• I actually did start with few example codes, I managed to make my SPI works and I even managed to make the ADC work using the HAL library. Over, I still do not get why it is not working using the basics library using a very similar code. Also, it is an eval board, so there should be no connection problems. – Nathaniel Brochu Feb 24 '19 at 19:25
• Start over from the working example and migrate it step by step towards your need, testing at each change (setting up version control like git would be great for this). – Chris Stratton Feb 24 '19 at 19:57
• I mean, I was already doing that, but it gave me the idea to remove one per one the line in the HAL library to see only what was necessary. In the end, I did manage to find my problem! If anyone ever happens to search for the solution here it is: First, I did mess up this line : RCC_APB2PeriphCLOCKCmd(RCC_APB2Periph_ADC1, ENABLE); But it is also necessary on the STM32L100C to activate the HSI oscillator clock, which is not done in the library. Adding this line with the RCC should work RCC -> CR |= (0x1U << (0U)); So thank you very much! – Nathaniel Brochu Feb 25 '19 at 3:43
• +1 Sounds like you have a solution. To resolve your question you should write that up more clearly in the "answer" form below and then accept it once the self-answer timer expires. – Chris Stratton Feb 25 '19 at 4:52

In the end, I did manage to find my problem! If anyone ever happens to search for the solution here it is: First, I did mess up this line :

RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE);


RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

RCC -> CR |= (0x1U << (0U));