diff --git a/source/Core/BSP/Magic/IRQ.cpp b/source/Core/BSP/Magic/IRQ.cpp index 9e514faf..d2e6de8a 100644 --- a/source/Core/BSP/Magic/IRQ.cpp +++ b/source/Core/BSP/Magic/IRQ.cpp @@ -63,7 +63,7 @@ static bool fastPWM = false; static void switchToFastPWM(void); volatile uint16_t PWMSafetyTimer = 0; -volatile uint8_t pendingPWM = 200; +volatile uint8_t pendingPWM = 0; volatile bool lastPeriodWasFast = false; // Timer 0 is used to co-ordinate the ADC and the output PWM @@ -91,6 +91,8 @@ void timer0_comp2_callback(void) { // Leave output off PWM_Channel_Disable(PWM_Channel); } + } else { + PWM_Channel_Disable(PWM_Channel); } } diff --git a/source/Core/BSP/Magic/Setup.cpp b/source/Core/BSP/Magic/Setup.cpp index 2d44f8ca..2a7bc875 100644 --- a/source/Core/BSP/Magic/Setup.cpp +++ b/source/Core/BSP/Magic/Setup.cpp @@ -34,6 +34,7 @@ void hardware_init() { gpio_write(TIP_RESISTANCE_SENSE, 0); MSG((char *)"Magic Starting\r\n"); + PWM_Channel_Disable(PWM_Channel); setup_timer_scheduler(); setup_adc(); setup_pwm(); @@ -57,6 +58,7 @@ void setup_pwm(void) { PWM_Channel_Init(&cfg); PWM_Channel_Disable(PWM_Channel); + gpio_set_mode(PWM_Out_Pin, GPIO21_FUN_PWM_CH1); } const ADC_Chan_Type adc_tip_pos_chans[] diff --git a/source/Core/BSP/Magic/configuration.h b/source/Core/BSP/Magic/configuration.h index 8efe0df0..eadf2eeb 100644 --- a/source/Core/BSP/Magic/configuration.h +++ b/source/Core/BSP/Magic/configuration.h @@ -127,7 +127,7 @@ #define POWER_LIMIT_STEPS 5 // #define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors #define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table -#define USB_PD_VMAX 28 // Maximum voltage for PD to negotiate +#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate #define PID_TIM_HZ (10) // Tick rate of the PID loop #define MAX_TEMP_C 450 // Max soldering temp selectable °C #define MAX_TEMP_F 850 // Max soldering temp selectable °F diff --git a/source/Core/BSP/Magic/peripheral_config.h b/source/Core/BSP/Magic/peripheral_config.h index bc3cc671..21b56915 100644 --- a/source/Core/BSP/Magic/peripheral_config.h +++ b/source/Core/BSP/Magic/peripheral_config.h @@ -93,7 +93,7 @@ #if defined(BSP_USING_PWM_CH1) #ifndef PWM_CH1_CONFIG #define PWM_CH1_CONFIG \ - { .ch = 1, .polarity_invert_mode = DISABLE, .period = 100, .threshold_low = 50, .threshold_high = 0, .it_pulse_count = 0, } + { .ch = 1, .polarity_invert_mode = DISABLE, .period = 100, .threshold_low = 0, .threshold_high = 0, .it_pulse_count = 0, } #endif #endif diff --git a/source/Core/BSP/Magic/pinmux_config.h b/source/Core/BSP/Magic/pinmux_config.h index 9fa10ec0..302d60bc 100644 --- a/source/Core/BSP/Magic/pinmux_config.h +++ b/source/Core/BSP/Magic/pinmux_config.h @@ -109,7 +109,7 @@ // GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC] // config gpio21 function -#define CONFIG_GPIO21_FUNC GPIO21_FUN_PWM_CH1 +// #define CONFIG_GPIO21_FUNC GPIO21_FUN_PWM_CH1 // GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC] // config gpio22 function