You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following the tutorial using a Raspberry Pi Pico device. I am able to get the Blinking LED example to work, however the Using PWM tutorial fails to compile with the following error:
$ tinygo flash -target=pico
# pwm-blinky
main.go:12:22: NewPWM not declared by package machine
If I alter the sample code as shown below, I am able to successfully compile the script and get the PWM working as expected on the Pico.
It seems that the current implementation (src) is missing the NewPWM function and instead has a similar looking function PWMPeripheral, but that returns the slice index of the PWM group, not a pointer to the initialized peripheral.
Perhaps a solutions could be to include the NewPWM function like this:
// NewPWM calls PWMPeripheral to get the RP2040 PWM peripheral slice number that// corresponds to the package's PWM0 throughout PWM7 handler.funcNewPWM(pinPin) (pwm*pwmGroup, errerror) {
sliceNum, err:=PWMPeripheral(pin)
iferr!=nil {
returnnil, err
}
returngetPWMGroup(sliceNum)
}
The text was updated successfully, but these errors were encountered:
It seems the tinygo site is outdated, as all NewPWM API has been removed as of the PWM interface refactor. I believe @aykevl was working on creating a better PWM page on tinygo.org to better reflect these changes.
Technical details aside, I agree we are missing some sort of API to get the underlying PWM peripheral from a pin. Right now it is quite unwieldy to do this user-side. I'm unsure why this was removed in the first place and whether it would be OK to add it as you have shown or some other way.
I am following the tutorial using a Raspberry Pi Pico device. I am able to get the Blinking LED example to work, however the Using PWM tutorial fails to compile with the following error:
$ tinygo flash -target=pico # pwm-blinky main.go:12:22: NewPWM not declared by package machine
If I alter the sample code as shown below, I am able to successfully compile the script and get the PWM working as expected on the Pico.
It seems that the current implementation (src) is missing the
NewPWM
function and instead has a similar looking functionPWMPeripheral
, but that returns the slice index of the PWM group, not a pointer to the initialized peripheral.Perhaps a solutions could be to include the
NewPWM
function like this:The text was updated successfully, but these errors were encountered: