Microsoft MakeCode

Regression: analogWrite to A0

Calling pins.A0.analogWrite(0) reliably crashes the CPX. analogWrite to other pins is fine. There are a number of reports about this scattered around GitHub + various forums, but I haven’t found anything in the way of solutions.

The panic code is DEVICE_HARDWARE_CONFIGURATION_ERROR (90 decimal, 0x5a). I found that the panic is a regression between 1.2.13 and 1.3.1. - code runs:
Adafruit Circuit Playground Express version: 1.2.13
Microsoft MakeCode version: 5.1.5
codal-circuit-playground runtime version: v1.5.6 - same code causes panic:
Adafruit Circuit Playground Express version: 1.3.1
Microsoft MakeCode version: 5.5.25
codal-circuit-playground runtime version: v1.5.4-samd-peripherals.10

Given that the regression is a couple years old at this point I assume it won’t be addressed upstream. I’m interested in writing a fix or a workaround, but need some guidance. I need to use A0; my ultimate goal is to write PCM audio to the speaker.

I have a basic c++ extension (pxt-banana) working on the CPX, but need help addressing pin a0 from c++. I hoped I could do something like this:

	auto pinSpkr = LOOKUP_PIN(A0);

However even that is crashing. MakeCode can play music through the speaker so I know that the hardware is fine; it’s something about analog writes to A0 that’s not quite right. Any advice would be welcome!