It almost works... This code:
console.log("Peek 0x40010800:", peek32(0x40010800)); digitalWrite(A0,0); // just set into output mode console.log("Peek 0x40010800:", peek32(0x40010800)); poke32(0x40010800, (peek32(0x40010800) & (~0b1100)) | 0b1100); // mask out existing bits and set open drain console.log("Peek 0x40010800:", peek32(0x40010800)); analogWrite(A0, 0.5, { freq : 100 } ); // Set PWM 50%, 100Hz console.log("Peek 0x40010800:", peek32(0x40010800)); poke32(0x40010800, (peek32(0x40010800) & (~0b1100)) | 0b1100); // mask out existing bits and set open drain again console.log("Peek 0x40010800:", peek32(0x40010800));
Gives this output:
Peek 0x40010800: 7 Peek 0x40010800: 3 Peek 0x40010800: 15 Peek 0x40010800: 11 Peek 0x40010800: 15
I think the analogWrite clearing the output type might be down to jshPinSetFunction() where it does:
bool remap = (func&JSH_MASK_AF)!=JSH_AF0; if ((func&JSH_MASK_TYPE)==JSH_TIMER1) GPIO_PinRemapConfig( GPIO_FullRemap_TIM1, remap ); else if ((func&JSH_MASK_TYPE)==JSH_TIMER2) GPIO_PinRemapConfig( GPIO_FullRemap_TIM2, remap ); else if ((func&JSH_MASK_TYPE)==JSH_TIMER3) GPIO_PinRemapConfig( GPIO_FullRemap_TIM3, remap ); ...
@dprime started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It almost works...
This code:
Gives this output:
ok.
I think the analogWrite clearing the output type might be down to jshPinSetFunction() where it does: