2019-10-24 03:55 PM
Hi, I'm new with stm32 and I want to get a simple 1Hz square wave in a NUCLEO-F446RE using CubeMX for the initial config. The code is so simple that I can't figure out where the problem is.
I just do:
while (1)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_8);
HAL_Delay(500);
}
and my GPIO configuration:
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, LD2_Pin|GPIO_PIN_8, GPIO_PIN_RESET);
/*Configure GPIO pin : B1_Pin */
GPIO_InitStruct.Pin = B1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : LD2_Pin PA8 */
GPIO_InitStruct.Pin = LD2_Pin|GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
But the signal I get:
As I've seen, that distortion is not that big if I increase the frequency:
But still there. What's going on???
Thanks!
2019-10-24 05:04 PM
Is it April 1? You are kidding , right? Coupling should be DC, not AC.
2019-10-24 05:28 PM
I knew it had to be something very stupid but not that much! :face_with_tears_of_joy: thanks!!