var fs=require("fs");
fs.readdir(); //This will work
analogWrite(A8,0);
fs.readdir(); //This will not
poke16(0x40012C20,peek16(0x40012c20)&0xFBBB); //turn off all the negated outputs on TIM1
fs.readdir(); // Works again!
Of course, every time you call analogWrite(A8), it gets reset...
Here we go - PWM on A8~10 without clobbering SPI2. If you enable PWM for A9 or A10, it'll move the USART out of the way, too.
//pass true for each pin you want to use.
function PWMsetup(a8,a9,a10) {
if (a8) {
analogWrite(A8,0);
}
if (a9||a10) {
poke8(0x40010004,peek8(0x40010004)|4); //move the USART out of the way
}
if (a9) {
analogWrite(A9,0);
}
if (a10) {
analogWrite(A10,0);
}
poke16(0x40012C20,peek16(0x40012c20)&0xFBBB);
}
function A8PWM(val) {
poke16(0x40012C34,E.clip(val*65535,0,65535));
}
function A9PWM(val) {
poke16(0x40012C38,E.clip(val*65535,0,65535));
}
function A10PWM(val) {
poke16(0x40012C3C,E.clip(val*65535,0,65535));
}
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.
Aaahahhaaha! This is so cool...
Of course, every time you call analogWrite(A8), it gets reset...
Here we go - PWM on A8~10 without clobbering SPI2. If you enable PWM for A9 or A10, it'll move the USART out of the way, too.