@@ -101,9 +101,10 @@ void debug_print_flexpwm_registers(PWM_Type *base) {
101
101
base -> FSTS , base -> FFILT , base -> FTST , base -> FCTRL2 );
102
102
for (uint8_t i = 0 ; i < 4 ; i ++ ) {
103
103
mp_printf (& mp_plat_print ,
104
- "\t\t(%u) INIT:%x CTRL2:%x CTRL:%x VAL0:%x VAL1:%x VAL2:%x VAL3:%x VAL4:%x VAL5:%x OCTRL:%x DTCNT0:%x DTCNT1:%x\n" , i ,
104
+ "\t\t(%u) INIT:%x CTRL2:%x CTRL:%x VAL0:%x VAL1:%x VAL2:%x VAL3:%x VAL4:%x VAL5:%x OCTRL:%x DTCNT0:%x DTCNT1:%x DISMAP: %x %x \n" , i ,
105
105
base -> SM [i ].INIT , base -> SM [i ].CTRL2 , base -> SM [i ].CTRL , base -> SM [i ].VAL0 , base -> SM [i ].VAL1 , base -> SM [i ].VAL2 ,
106
- base -> SM [i ].VAL3 , base -> SM [i ].VAL4 , base -> SM [i ].VAL5 , base -> SM [i ].OCTRL , base -> SM [i ].DTCNT0 , base -> SM [i ].DTCNT1 );
106
+ base -> SM [i ].VAL3 , base -> SM [i ].VAL4 , base -> SM [i ].VAL5 , base -> SM [i ].OCTRL , base -> SM [i ].DTCNT0 , base -> SM [i ].DTCNT1 ,
107
+ base -> SM [i ].DISMAP [0 ], base -> SM [i ].DISMAP [1 ]);
107
108
}
108
109
109
110
}
@@ -183,23 +184,11 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
183
184
self -> pwm -> pwm -> SM [self -> pwm -> submodule ].DISMAP [1 ] = 0 ;
184
185
185
186
DBGPrintf (& mp_plat_print , "\tCall PWM_SetupPwm %p %x %u\n" , self -> pwm -> pwm , self -> pwm -> submodule );
186
- #if 0
187
+ // ========================================================================================================
187
188
// Not calling the PWM_SetupPwm as it was setup to only work for PWM output on chan A and B but not X
188
189
// I have done some experimenting, probably could try others, but again they do not work with X.
189
190
// Most of the code checks to see if A if not, then it assume B.
190
- pwm_signal_param_t pwmSignal = {
191
- .pwmChannel = self -> pwm -> channel ,
192
- .level = kPWM_HighTrue ,
193
- .dutyCyclePercent = 0 , // avoid an initial transient
194
- .deadtimeValue = 0 , // allow 100% duty cycle
195
- };
196
- status_t status = PWM_SetupPwm (self -> pwm -> pwm , self -> pwm -> submodule , & pwmSignal , 1 , kPWM_EdgeAligned , frequency , PWM_SRC_CLK_FREQ );
197
-
198
- if (status != kStatus_Success ) {
199
- return PWMOUT_INITIALIZATION_ERROR ;
200
- }
201
- #else
202
- // ========================================================================================================
191
+ //
203
192
// Instead I set it up to work similar to what the Teensy 4.x code does.
204
193
//
205
194
// That is we set the PWM_CTRL_FULL_MASK, which then uses base->SM[submodule].VAL1 to control
@@ -237,8 +226,6 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
237
226
}
238
227
debug_print_flexpwm_registers (self -> pwm -> pwm );
239
228
240
- #endif
241
-
242
229
PWM_SetPwmLdok (self -> pwm -> pwm , 1 << self -> pwm -> submodule , true);
243
230
244
231
PWM_StartTimer (self -> pwm -> pwm , 1 << self -> pwm -> submodule );
0 commit comments