cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 GPIO Configuration

Khoo.B
Associate III

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Khoo.B
Associate III

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.

View solution in original post

6 REPLIES 6
Khoo.B
Associate III

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

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
Associate III

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!

> Only drive with open collector

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

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
Up vote any posts that you find helpful, it shows what's working..
Khoo.B
Associate III

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.