File tree Expand file tree Collapse file tree
ports/broadcom/common-hal/neopixel_write Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
9797 COMPLETE_MEMORY_READS ;
9898 icnt = 0 ;
9999 while ((CM_PWM -> CS_b .BUSY == 0 ) & (icnt ++ < 1000 )) {
100+ COMPLETE_MEMORY_READS ;
100101 }
101102 }
102103
@@ -142,19 +143,22 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
142143 icnt = 0 ;
143144 while ((pwm -> STA_b .FULL1 == 1 ) & (icnt ++ < 150 )) {
144145 RUN_BACKGROUND_TASKS ;
146+ COMPLETE_MEMORY_READS ;
145147 }
146148 // Dummy value for the first channel.
147149 pwm -> FIF1 = 0x000000 ;
148150 }
149151 icnt = 0 ;
150152 while ((pwm -> STA_b .FULL1 == 1 ) & (icnt ++ < 150 )) {
151153 RUN_BACKGROUND_TASKS ;
154+ COMPLETE_MEMORY_READS ;
152155 }
153156 pwm -> FIF1 = expanded ;
154157 if (channel == 0 ) {
155158 icnt = 0 ;
156159 while ((pwm -> STA_b .FULL1 == 1 ) & (icnt ++ < 150 )) {
157160 RUN_BACKGROUND_TASKS ;
161+ COMPLETE_MEMORY_READS ;
158162 }
159163 // Dummy value for the second channel.
160164 pwm -> FIF1 = 0x000000 ;
@@ -164,17 +168,23 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
164168 icnt = 0 ;
165169 while ((pwm -> STA_b .EMPT1 == 0 ) & (icnt ++ < 2500 )) {
166170 RUN_BACKGROUND_TASKS ;
171+ COMPLETE_MEMORY_READS ;
167172 }
168173 // Wait for transmission to start.
169174 icnt = 0 ;
170175 while (((pwm -> STA_b .STA1 == 0 ) & (pwm -> STA_b .STA2 == 0 )) & (icnt ++ < 150 )) {
171176 RUN_BACKGROUND_TASKS ;
177+ COMPLETE_MEMORY_READS ;
172178 }
173179 // Wait for transmission to complete.
174180 icnt = 0 ;
175181 while (((pwm -> STA_b .STA1 == 1 ) | (pwm -> STA_b .STA2 == 1 )) & (icnt ++ < 150 )) {
176182 RUN_BACKGROUND_TASKS ;
183+ COMPLETE_MEMORY_READS ;
177184 }
185+ // Shouldn't be anything left in queue but clear it so the clock doesn't crash if there is
186+ pwm -> CTL = PWM0_CTL_CLRF1_Msk ;
187+ COMPLETE_MEMORY_READS ;
178188
179189 gpio_set_function (digitalinout -> pin -> number , GPIO_FUNCTION_OUTPUT );
180190
You can’t perform that action at this time.
0 commit comments