# Regression: analogWrite to A0

**URL:** https://forum.makecode.com/t/regression-analogwrite-to-a0/5725
**Category:** Adafruit Circuit Playground Express
**Created:** [January 24, 2021, 3:38pm UTC](https://forum.makecode.com/t/regression-analogwrite-to-a0/5725 "2021-01-24T15:38:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![smagoun](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@smagoun](https://forum.makecode.com/u/smagoun)
#### Post date: [January 24, 2021, 3:38pm UTC](https://forum.makecode.com/t/regression-analogwrite-to-a0/5725/1 "2021-01-24T15:38:35Z")

</div>

Calling `pins.A0.analogWrite(0)` reliably crashes the CPX. analogWrite to other pins is fine. There are a number of [reports](https://github.com/microsoft/pxt-adafruit/issues/1061) 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.

[https://makecode.adafruit.com/v1.2.13#editor](https://makecode.adafruit.com/v1.2.13#editor) - code runs:  
Adafruit Circuit Playground Express version: 1.2.13  
Microsoft MakeCode version: 5.1.5  
codal-circuit-playground runtime version: v1.5.6

[https://makecode.adafruit.com/v1.3.1#editor](https://makecode.adafruit.com/v1.3.1#editor) - 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);
	pinSpkr->setAnalogValue(val);

```

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!
