Hello,
I modified bone script pwm.js from Derek Molloy book, adapting pin for BBB (in bold):
var b = require('bonescript');
var pin = "P9_21"; // Use P1.08 or P1.36 by default on PocketBeagle
var dutyCycle = 0.75;
var frequency = 10000;
b.pinMode(pin, b.OUTPUT);
b.getPinMode(pin, printPinMux);
b.analogWrite(pin, dutyCycle, frequency, display);
function printPinMux(val){
console.log('mux = '+val.mux);
console.log('name = '+val.name);
}
function display(val){
console.log(val);
}
Doesn't work:
debian@beaglebone:~/exploringbb/chp06/bone$ sudo nodejs pwm.js
error: error updating PWM freq and value: /sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:1, Error: EINVAL: invalid argument, write
{ err:
'error updating PWM freq and value: /sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:1, Error: EINVAL: invalid argument, write' }
warning: single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)
mux = undefined
name = UART2_TXD
Any suggestions ?
Thanks.