File tree Expand file tree Collapse file tree
ports/atmel-samd/common-hal/pulseio Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
151151 // one output so we start with the TCs to see if they work.
152152 int8_t direction = -1 ;
153153 uint8_t start = NUM_TIMERS_PER_PIN - 1 ;
154+ bool found = false;
154155 if (variable_frequency ) {
155156 direction = 1 ;
156157 start = 0 ;
@@ -162,6 +163,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
162163 continue ;
163164 }
164165 if (t -> is_tc ) {
166+ found = true;
165167 Tc * tc = tc_insts [t -> index ];
166168 if (tc -> COUNT16 .CTRLA .bit .ENABLE == 0 && t -> wave_output == 1 ) {
167169 timer = t ;
@@ -177,7 +179,11 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
177179 }
178180
179181 if (timer == NULL ) {
180- mp_raise_RuntimeError ("All timers in use" );
182+ if (found ) {
183+ mp_raise_ValueError ("All timers for this pin are in use" );
184+ } else {
185+ mp_raise_RuntimeError ("All timers in use" );
186+ }
181187 return ;
182188 }
183189
You can’t perform that action at this time.
0 commit comments