Electronics > Microcontrollers

STM32 ADC pins structure

(1/1)

cyberfish:
Just wondering if someone has experience with STM32 ADCs?

My question is: Is it possible to do GPIO operations on ADC input pins with the ADC active?

It seems to be the case from the reference manual (http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENCE_MANUAL/CD00225773.pdf, page 206), but I just want to make sure, since for most other peripherals, enabling the peripheral disables GPIO functions on associated pins.

In my case, I wish to talk to a 4-wire touch screen, which means I will have to alternatively drive some of those 4 pins high, low, and float (ADC read). I wouldn't be able to drive the pins if enabling the ADC disables their GPIO functions.

Thanks!

hisense999:
I not clearly understand your design if is about you want use one pin for example PA0 as ADC input and also as some input or output in same time or you are just worry enabling ADC will disable all pins mentioned in datasheet ? If is about second option then don't worry all pins use routing interface so as long as you don't map pin as AF then peripherials don't have access into it and is working as standard GPIO. For example if you enable ADC without map any pin mentioned in datasheet into ADC AF then you will get ADC which is connected to nothing but working.
 
But if it is about first option then just change on the fly the function of pin from Alternate Function (AF) into IN\OUT running peripherial don't means this pin is connected into it, choosing of pin function you doing by your own so just change pin function into IN\OUT when you need it and then map it again as AF this will works. In this case don't care too much about ADC descriptions more look at GPIO descriptions and functions in datasheet.

B.R.

cyberfish:
It's the second option. That's for clearing that up!

hisense999:
Then don't worry, datasheet only show which pins which you can use with ADC but without your interaction will not take any pin by itself, to connect pins which you want first you must connect it to ADC


This is taken from STM32 library example:


/**
  * @brief  Configures the different GPIO ports.
  * @param  None
  * @retval None
  */
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  /* Configure PC.02, PC.03 and PC.04 (ADC Channel12, ADC Channel13 and
     ADC Channel14) as analog inputs */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
}

So here only 3 channels of ADC are configuret as Alternate Input, by default all IO ports (except JTAG ports) are configured as general GPIO pins which are not connected to any special peripherials, just datasheet always show to you possible connections with peripherials which you can do using Alternate functions of GPIO pins.

B.R.

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod