Examination of your code makes me wonder what you're doing in pid.c with code that appears to do nothing.
Code:
/*
* gpio.h
*
* Created on: Nov 4, 2015
* Author: mcm
*/
#include "stm32f1xx_hal.h"
#ifndef GPIO_H_
#define GPIO_H_
#define STATUS_LED (GPIO_PIN_13)
#define ERROR_LED (GPIO_PIN_14)
#define ENABLE_POWER_STAGE (GPIO_PIN_0)
#define LEDS_PORT (GPIOC)
#define POWER_STAGE_PORT (GPIOB)
Code:
/*
* pid.c
*
* Created on: Oct 15, 2015
* Author: mcm
*/
#include "encoders.h"
#include "ExtInt.h"
#include "stm32f1xx_hal.h"
#include "servo_config.h"
#include "pid.h"
#include "pwm.h"
#include "gpio.h"
#include "usb_device.h"
#include "usbd_hid.h"
PIDStatus_TypeDef PID_Status = PID_Stopped;
uint8_t Must_Init_Motor = 1;
int32_t Position_Error, Old_Position_Error;
uint16_t Unsigned_Position_Error;
int32_t Integral;
void PID_Start(void)
{
if(PID_Status == PID_Started)
return;
PWM_Init_Motor();
Pin_off(LEDS_PORT, ERROR_LED);
Pin_on(POWER_STAGE_PORT, ENABLE_POWER_STAGE);
PID_Status = PID_Started;
}
void PID_Stop(void)
{
if (PID_Status != PID_Started)
return;
PID_Status = PID_Stopped;
Pin_off(POWER_STAGE_PORT, ENABLE_POWER_STAGE);
PWM_Stop_Motor();
Unsigned_Position_Error = 0;
}
Since you're not doing anything on PORTB except for the three complimentary TIM1's and EN/DIR/STEP and have nothing connected to GPIOB GPIO_PIN_0, what exactly are you doing here as this seems to do nothing by turning on/off PB0?