cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476VGT6 pin PC13 odd behaviour

mathieson
Associate
Posted on August 05, 2016 at 00:16

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.

#stm32l476-pc13-usb
2 REPLIES 2
Posted on August 05, 2016 at 01:44

What happens if you remove the SPI device and just wiggle the lines?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 05, 2016 at 11:01

Also, tell us more about your supply and grounding arrangement, especially around VBAT; how PC14-PC15 are used; what's your clock arrangement. Have you looked at PC13 with an oscilloscope? You might also want to observe the clock output to MCO while wiggling PC13.

JW