AnsweredAssumed Answered

STM32L476VGT6 pin PC13 odd behaviour

Question asked by mathieson.charles on Aug 5, 2016
Latest reply on Aug 5, 2016 by waclawek.jan

We have had an odd problem with using pin PC13 as an output GPIO (for active-low chip-select of a bit-banged SPI).  (PC13 is not defined as a GPIO_EXTI13.)  We found that controlling this GPIO somehow leads to USB (USB_OTG_FS) virtual com port operations getting locked up. 

What I mean by “USB locked up” is that USB software driver ends up in state thinking that last USB transmit request is outstanding forever, i.e. did not receive transmit complete interrupt from USB peripheral (i.e. stuck with hcdc->TxState == 1).

We would like to have understanding why this output PC13 GPIO causes USB operations to lock up.

As a workaround, we added an extra GPIO toggle before and after each SPI interaction so that this output GPIO is in opposite polarity i.e. low (to expected high polarity) while idle between SPI operations.

We did experiment where add preamble and post-amble sequence to procedure for writing a value to a SPI device.  Normal SPI transaction includes:
drop chip-select, send series of SPI data bits, raise chip-select.  
Modified SPI transaction adds extra chip-select toggle before and after transaction, i.e.:
set chip-select line high, set chip-select low, send data bits, set chip-select high, set chip-select line low.

(This experiment made big difference.  Able to do 10,000 SPI operations without USB getting hung up.  We don't understand why this helps.  Without the workaround, the USB locks up after some hundreds of transactions done on the bit-banged SPI.)

“STM32L4x6 advanced ARM based 32-bit MCUs Reference manual” (RM0351) section 5.3 talks about Low-Power modes.  Section 5.1.5 talks about interactions between pin PC13 and the RTC.

We are not using the RTC peripheral so don’t expect the relationship between PC13 and RTC to apply.

Reference manual section 7.3.14 ("Using the GPIO pins in the RTC supply domain") states PC13 functionality is lost when the core supply domain is powered off (i.e. when device enters Standby Mode).  We have not used any standby or sleep modes yet, so don’t expect this to apply.

We wish to understand relationship between this PC13 used as a output GPIO (for SPI chip select) and USB lock-up.

We confirmed that no low power states are in play.

We confirmed that we don't have any EXTI13 interrupt enabled.  There is no option in the Cube tool to define such EXTI13 interrupt unless one of the P?13 pins is defined with type GPIO_EXTI13.


Outcomes