Fix timer output

This commit is contained in:
Ben V. Brown
2022-07-01 17:54:54 +10:00
parent e174dba676
commit 7614a5b92b
2 changed files with 3 additions and 4 deletions

View File

@@ -87,7 +87,6 @@ void timer0_comp2_callback(void) {
// Turn on output // Turn on output
PWM_Channel_Enable(PWM_Channel); PWM_Channel_Enable(PWM_Channel);
} else { } else {
TIMER_SetCompValue(TIMER_CH0, TIMER_COMP_ID_1, 0);
// Leave output off // Leave output off
PWM_Channel_Disable(PWM_Channel); PWM_Channel_Disable(PWM_Channel);
} }

View File

@@ -34,13 +34,11 @@ void hardware_init() {
gpio_write(TIP_RESISTANCE_SENSE, 0); gpio_write(TIP_RESISTANCE_SENSE, 0);
MSG((char *)"Magic Starting\r\n"); MSG((char *)"Magic Starting\r\n");
PWM_Channel_Disable(PWM_Channel);
setup_timer_scheduler(); setup_timer_scheduler();
setup_adc(); setup_adc();
setup_pwm(); setup_pwm();
I2C_ClockSet(I2C0_ID, 300000); // Sets clock to around 275kHz I2C_ClockSet(I2C0_ID, 300000); // Sets clock to around 275kHz
TIMER_SetCompValue(TIMER_CH0, TIMER_COMP_ID_1, 0); TIMER_SetCompValue(TIMER_CH0, TIMER_COMP_ID_1, 0);
PWM_Channel_Enable(PWM_Channel);
} }
void setup_pwm(void) { void setup_pwm(void) {
// Setup PWM we use for driving the tip // Setup PWM we use for driving the tip
@@ -49,7 +47,7 @@ void setup_pwm(void) {
PWM_CLK_XCLK, // Clock PWM_CLK_XCLK, // Clock
PWM_STOP_ABRUPT, // Stop mode PWM_STOP_ABRUPT, // Stop mode
PWM_POL_NORMAL, // Normal Polarity PWM_POL_NORMAL, // Normal Polarity
50, // Clock Div 60, // Clock Div
100, // Period 100, // Period
0, // Thres 1 - start at beginng 0, // Thres 1 - start at beginng
50, // Thres 2 - turn off at 50% 50, // Thres 2 - turn off at 50%
@@ -151,6 +149,8 @@ void setupFUSBIRQ() {
void vAssertCalled(void) { void vAssertCalled(void) {
MSG((char *)"vAssertCalled\r\n"); MSG((char *)"vAssertCalled\r\n");
PWM_Channel_Disable(PWM_Channel);
gpio_set_mode(PWM_Out_Pin, GPIO_INPUT_PD_MODE);
while (1) while (1)
; ;