Skip to main content
Khoo.B
Associate III
December 26, 2018
Solved

STM32L152 GPIO Configuration

  • December 26, 2018
  • 6 replies
  • 3096 views

Hi,

I would like to control a GPS module reset pin thru STM32L152. The reference circuit of the GPS module reset pin as per attached picture. According to the GPS data sheet, the reset pin "Only drive with open collector, no external voltage to be applied".

0690X000006Cv8PQAS.jpg

How should I configure my GPIO connected to the reset pin? I tried this but it doesn't seem to work:

 // GPIO initialisation
	GPIO_InitTypeDef GPIO_InitStruct;
 
	// Enable clock for GPIOC
	__HAL_RCC_GPIOC_CLK_ENABLE();
 
	// Initialise watchdog pin
	GPIO_InitStruct.Pin = GPS_RESET_PIN;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
	HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
 HAL_GPIO_WritePin(GPIOC, GPS_RESET_PIN, GPIO_PIN_SET);
 HAL_Delay(100);
 HAL_GPIO_WritePin(GPIOC, GPS_RESET_PIN, GPIO_PIN_RESET);
 HAL_Delay(100);

Thank you very much!

This topic has been closed for replies.
Best answer by Khoo.B

Thank you everyone! I have sorted it out. I just need to keep it low for a longer period to reset the GPS module. Thanks once again.

6 replies

Khoo.B
Khoo.BAuthor
Associate III
December 26, 2018

I actually connect the GPIO pin of STM32 directly to the reset pin of GPS module.

After Forever
Senior III
December 26, 2018

If it doesn't have internal pull-up you may want to use GPIO_PULLUP instead of GPIO_NOPULL. Do it on your own risk though, also I don't think it can do any harm even if I'm wrong.

Khoo.B
Khoo.BAuthor
Associate III
December 26, 2018

Thanks for the suggestion. I tried using GPIO_PULLUP but it doesn't seem to work also.

Should I use GPIO_MODE_OUTPUT_OD or GPIO_MODE_OUTPUT_PP?

Thanks!

After Forever
Senior III
December 26, 2018

> Only drive with open collector

You are right to set it to GPIO_MODE_OUTPUT_OD (OD == open drain == open collector).

Tesla DeLorean
Guru
December 26, 2018

Likely expects the pin to be pulsed low briefly. If you keep it low it will stay in reset. I'd look at the data sheet but you fail to provide a cite.

Check level on pin, confirm it has a pull-up.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Khoo.B
Khoo.BAuthorBest answer
Associate III
December 27, 2018

Thank you everyone! I have sorted it out. I just need to keep it low for a longer period to reset the GPS module. Thanks once again.