cancel
Showing results for 
Search instead for 
Did you mean: 

Pin on STM32L4P5VGT6 interfering with ADC PC3 and PC2

flatirondesigns
Associate II

I made a mistake and set PC2 as an ADC input and PC3 as an GPIO_EXT. The IDE does not warn you when setting the pin to GPIO_EXT, it only shows the warning in the ADC, so I missed it since the ADC was already set.

The question is, is there anyway to make this work. The issue I am seeing is the ADC is reading incorrectly. The GPIO_EXT works fine. 

Thanks.

6 REPLIES 6
waclawek.jan
Super User

What do you want to accomplish, exactly?

I don't use Cube/HAL, so I only have to guess that "GPIO_EXT" - which is not to be found in Datasheet or Reference Manual - means that you set PC3 to trigger an EXTI interrupt, and that in turn you set it also to Input in the respective GPIOx_MODER.

But I don't know, which pin(s) do you want to take ADC readings for, PC2, PC3 or both? You can't use PC3 as ADC input and EXTI trigger simultaneously, as ADC requires the pin to be set as Analog in GPIOx_MODER and that disconnects the digital input buffer at that pin.

Otherwise, what is the expected reading, what is the signal source, what is the ADC sampling set to, and how do you know the ADC is reading incorrectly?

JW

TDK
Super User

If you want to use PC2 as an ADC input and PC3 as GPIO_EXTI, there is no issue. If your ADC isn't reading correctly, it's not related to PC3. Consider adding more clarity and detail to your question.

If you feel a post has answered your question, please click "Accept as Solution".
flatirondesigns
Associate II

Sorry for the lack of detail. I assume this is a known thing that I didn't know.

The situation is pretty simple.

I have PC2 set up as IN3 on ADC2 singled ended.

I have PC3 set up as GPIO_EXTI3

STM32CubeIDE flags PC2 with a yellow caution. The message says "IN3 conflict with PC3 mapped as GPIO_EXTI3".

I also have IN1 and IN2 hooked up and they work fine. I also have eight other ADC inputs on ADC1 and they work fine.

A simple test is to ground PC2 and it does not read zero or even close. It reads ~2000(raw adc value). 

Next, I reset PC3 so it is no longer an input, the warning goes away and now PC2 works as expected.

Maybe the Cube is generating bad initialization code? I guess it could be but seems pretty straight forward. 

Perhaps my ADC settings(below) are causing the conflict? 

flatirondesigns_0-1768186599259.png

As stated, all the other ADC inputs work fine, so I am confident the code is sound.

> Maybe the Cube is generating bad initialization code? I guess it could be but seems pretty straight forward. 
> Perhaps my ADC settings(below) are causing the conflict? 

I don't see a reason why the configurations of PC2 and PC3 should interfere with each other.
I never experienced such an issue on any part I worked with - although a L4 device was amongst them.
It is well-known that Cube has more than one bug.

I would suggest review the actual peripheral register settings after the setup routine in a debugger.
This requires some reading and cross-referencing with the MCU's RM, though.

TDK
Super User

You have 9 inputs on the ADC but the initialization code only shows 1. There's nothing wrong with what you've provided. The bug is elsewhere.

If you feel a post has answered your question, please click "Accept as Solution".
flatirondesigns
Associate II

Thanks everyone for not letting me be lazy. I should have gone with my gut(I have been doing this a long time). I assumed I was doing something and wasn't, but was fooled by the data.

Basically, I thought I was doing a read/modify/write and was really doing just modify/write of the ADC2 config.

Thanks again.