2021-05-06 11:36 AM
I have a board with a STM32F103RET6 with many things, and a blue and green LED's connected to GPIO pins. To test if it works correctly I'm using STM32 cube IDE to upload a program that blinks the LED's, and the LED turns on but it does not turn off after the delay. I have tried with both LEDs i have and it happens the same in both of them, the one I select turns on but it does not turn off (won't blink). The code I'm using is as follows:
#include "main.h"
#include "usb_device.h"
I2C_HandleTypeDef hi2c1;
SPI_HandleTypeDef hspi1;
TIM_HandleTypeDef htim1;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
TIM_HandleTypeDef htim4;
UART_HandleTypeDef huart3;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_TIM1_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM3_Init(void);
static void MX_TIM4_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_I2C1_Init(void);
static void MX_SPI1_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM1_Init();
MX_TIM2_Init();
MX_TIM3_Init();
MX_TIM4_Init();
MX_USART3_UART_Init();
MX_I2C1_Init();
MX_SPI1_Init();
MX_USB_DEVICE_Init();
while (1)
{
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, 1);
HAL_Delay(500);
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, 0);
HAL_Delay(500);
}
}
I have also tried with HAL_GPIO_TogglePin and I get the same results. I believe the problem is not in the coding, as it is really simple, so there must be something with the clock configuration. I'm using an external oscillator at 16 MHz.
Thank you for your time.
2021-05-06 11:47 AM
Try using the debugger to understand what is and is not actually happening.
Check it is not stuck in Error_Handler() or some other while(1) loop within the code.
The code here is pretty superficial.
2021-05-06 12:17 PM
When debugging, the following message pops up:
No source available for "uwTickPrio() at 0x20000004"
Any ideas where else should i look at?
2021-05-07 01:00 AM
what happens if you comment out all of these?
MX_GPIO_Init();
// MX_TIM1_Init();
// MX_TIM2_Init();
// MX_TIM3_Init();
// MX_TIM4_Init();
// MX_USART3_UART_Init();
// MX_I2C1_Init();
// MX_SPI1_Init();
// MX_USB_DEVICE_Init();
What hardware are you using (bluepill maybe)?
Maybe your led is low side driven so it will be lit after reset.