cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0xx findings

Posted on November 14, 2016 at 22:07

In a new project there are several identical STM32F031 devices in a role of a slave mcu, driving LEDs and reading in various input signals. As their functionality is very similar, it is tempting to have only one single binary to simplify production. However, the devices have several different IO configurations, i.e. the LEDs and inputs are on different pins for the different role devices, so the program needs to ''know'' which configuration mcu is it running on.

My idea is to distinguish the configurations based on LEDs being connected to different pins on different configurations. There is always at least one pin for each particular configuration, where in that configuratio a LED is connected (anode to pin, cathode through resistor to ground) and in other configurations this pin serves as an input, guaranteed to be at logic 0 or 1 all the time. So the idea is to measure voltage while pullup is enabled - the LED would ensure cca 2V, whereas other pins would be at 3.3V VCC or GND.

So I went to the DS and RM0091rev.8 to re-read carefully the GPIO chapter. To my disappointment, the Analog configuration clearly reads that the pullups/pulldowns are disconnected (and I confirmed that that is the case indeed with a simple program).

However, DS says, for pins connected to ADC (all of them in this particular case), that they are of ''TTa'' type, ''3.3 V-tolerant I/O directly connected to ADC''. My reading of this is that, while the pulls are disconnected in Analog mode of pin, the analog input to ADC is NOT disconnected in every other mode - regardless of what the RM says and displays on the simplified schematics.

And, true enough, this works - setting the pins to ... whatever, input or OC output, the ADC reflects the true voltage on the pin. Of course I understand that the precision of readout may be slightly compromised by the digital input buffer loading and/or digital noise parasitically coupled through it, but in this particular case it does not matter.

So, my question to ST is, is there any cirumstance under which a TTa-marked pin woudln NOT be connected to ADC?

If none, could this fact (that ADC is connected to TTa pins also in non-Analog settings in GPIO) please be mentioned in the RMs?

---

Second observation relates to the ADC's clock. There is a dedicated 14MHz RC oscillator (HSI14), and by default that is selected as the ADC clock (the other option is the APB clock, and there is an explanation of pros and cons of both options in the RM, which is OK). However, the ADC chapter avoids using the ''HSI14'' name for this clock, which is confusing. I understand the reason (the glued-up-from-IPs nature of these chips unfortunately impacts also the documentation); but I'd like to ask ST to unify the variuos signals' names across the whole RM.

---

There is one more issue with this signal. This HSI14 clock can be switched on and off using  RCC_CR2.HSI14ON, and its current state is indicated by RCC_CR2.HSI14RDY. When the latter changes from 0 to 1, RCC_CIR.HSI14RDYF is set (pending enables it fires an interrupt). So far so good. HSI14 is promised (in ch.7.2.9) to be automatically switched on when selected and used(*) in the ADC (and this behaviour can be disabled by RCC_CR2.HSI14DIS which also works as promised). So I expected, that fiddling with ADC, I will see RCC_CR2.HSI14ON and/or RCC_CR2.HSI14RDY to go up. This did not happen, both bits remained at 0, although I confirmed through outputtin HSI14 to MCO that it (*) switched on either during calibration (and switched off automatically when calibration ended), or all the time while ADCEN was set (these circumstances when HSI14 gets enabled from ADC might perhaps deserve a mention, too).

So, I'd like to as ST to add a remark to  RCC_CR2.HSI14ON and RCC_CR2.HSI14RDY description in RM, that they are *unaffected* by the automatic-switchon-from-ADC. Note that there *is* such a remark at RCC_CIR.HSI14RDYF.

---

While fiddling with enabling/disabling the ADC and its clock, I noticed that in the Snippets in App. A, in very first example, prior to calibration there is a check if ADCEN is set, and if it is, there is an attempt to switch it off by clearing it. However, this can't be done as ADCEN can be cleared only by setting ADDIS (after ensuring a conversion is not running - as the third example demonstrates), so the presented snippet would lock up if the ADC was enabled before calibration. Can ST please correct this both in the RM and the Snippets.

-----

Thanks,

Jan Waclawek
5 REPLIES 5
Amel NASRI
ST Employee
Posted on February 20, 2017 at 15:23

Hi

Waclawek.Jan

‌,

Interesting feedback, as usual.

Here my answers for each case:

1-

is there any circumstance under which a TTa-marked pin would NOT be connected to ADC?

TTa-marked pins are used with analog peripherals (ADC, DAC, COMP) as it is the case in

http://www.st.com/content/ccc/resource/technical/document/datasheet/ae/84/f4/f9/ad/22/44/2f/DM00135pdf/files/DM00135pdf/jcr:content/translations/en.DM00135pdf

.

For the particular case of STM32F031, PA0 is a TTa pin used for ADC_IN0,RTC_TAMP2,WKUP1.

2-

the ADC chapter avoids using the 'HSI14' name for this clock, which is confusing

HSI14 is the 14 MHz RC oscillator connected on the ADC asynchronous clock input. In ADC chapter, we speak about 'ADC asynchronous clock'.

3-

So, I'd like to as ST to add a remark to RCC_CR2.HSI14ON and RCC_CR2.HSI14RDY description in RM, that they are *unaffected* by the automatic-switchon-from-ADC. Note that there *is* such a remark at RCC_CIR.HSI14RDYF.

This is already done in Rev9 of

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c2/f8/8a/f2/18/e6/43/96/DM000319pdf/files/DM000319pdf/jcr:content/translations/en.DM000319pdf

already on the web.

4-

While fiddling with enabling/disabling the ADC and its clock, I noticed that in the Snippets in App. A, in very first example, prior to calibration there is a check if ADCEN is set, and if it is, there is an attempt to switch it off by clearing it

This is already done in Rev9 of

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c2/f8/8a/f2/18/e6/43/96/DM000319pdf/files/DM000319pdf/jcr:content/translations/en.DM000319pdf

already on the web.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on February 20, 2017 at 23:43

Hi Amel,

Thanks for the reply and information.

Just to add for those who come to this thread through search:

TTa-marked pins are used with analog peripherals (ADC, DAC, COMP) as it is the case in

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fccc%2Fresource%2Ftechnical%2Fdocument%2Fdatasheet%2Fae%2F84%2Ff4%2Ff9%2Fad%2F22%2F44%2F2f%2FDM00135pdf%2Ffiles%2FDM00135pdf%2Fjcr%3Acontent%2Ftranslations%2Fen.DM00135pdf

. [...]

Related to this is

https://community.st.com/0D70X000006SufTSAS

from

teissier.maxime

On TTa pins, the upper clamping diode goes to VDDA due to the analog feature of the pin.

Jan

Max
ST Employee
Posted on February 21, 2017 at 03:59

I just want to add my 2 cents here.

Indeed, one of the most important feature of the of the analog setting of the GPIO is to disable the input Schmidt-trigger, pull-up and pull-down on the pin.

The pull-up and pull-down will definitely impact the analog signal on the pin, so this is implemented to improve the analog signal integrity.

Disabling the Schmidt-trigger  is done to reduce the GPIO pin consumption.

Like for any logic gate, the consumption is low when a logic level is applied to the input but  increase significantly when the voltage is around VDD/2.

This condition is likely to happen when the pin is used for an analog function.

you are probably impacted  with 2V on the pin with VDD=3.3V

So watch out for increased consumption if you use this in your application.

Also, on STM32F0, as you demonstrated, the ADC is directly connected to the GPIO.

This is probably not the case for all STM32 series, specially older ones like the STM32F1.

I don't know for sure, so I am not going to give you a list here, but do not take any undocumented feature for granted.

Test this again if you change to other series.

And do not forget, what is not specified is not guarantied... 

Max

Posted on February 21, 2017 at 12:33

So watch out for increased consumption if you use this [non-Analog setting of GPIO and analog(ADC) usage] in your application.

Point taken.

The 'F031 DS mentions this under I/O static current consumption, unfortunately without quantification.

I guess that input transistors are narrow enough to keep this current under a fraction of mA.

This is probably not the case for all STM32 series, specially older ones like the STM32F1.

Surely not on F4/F2, where ADC inputs are on FT pins, with the specific warning that they lose to be five-volt-tolerant as soon as switched to Analog.

JW

Posted on February 24, 2017 at 17:51

More.

In RM0091, rev.9, 3.5.1  Flash access control register (FLASH_ACR):

Reset value: 0x0000 0000

[...]

Bit 4 PRFTBE: Prefetch buffer enable

 0: Prefetch is disabled

In RM0091, rev.9, Prefetch controller  within 3.2.1:

After reset, the state of the prefetch buffer is on.

ST, please clarify.

Thanks,

JW