Unable to write to PWM Pin on Hexiwear Docking Station


When running the following code, I get the following error: TypeError @[0005:001B:0000:009B:0000:0000:0000:0000] which occurs at the analog.write Function. I would appreciate any guidance on how to resolve this issue. I have searched online to no avail.

import streams
from nxp.hexiwear import hexiwear
import threading
import zLogo
import pwm
hexi = hexiwear.HEXIWEAR()
hexi.draw_image(zLogo.zz, 38, 10, 20, 20)
hexi.draw_text(“Start!”, 0, 60, 96, 20, align=3, color=0xFFFF, background=0x0000, encode=False)
# while True:
print(“Outputting PWM”)
except Exception as e:
print(“PWM Outputted”)


Hi Pranav,

thanks for reporting this issue; we found a bug in our analogWrite() method that raised the TypeError you got when it is used as PWM control.
This will be fixed in our next update available very soon.

Anyway, long-term support for analogWrite() method is not guaranteed and, as suggested in our documentation, you can use the pwm.write() method to handle PWM pins.

Last advice: as reported in the NXP Kinetis K64 reference manual, PWM period has hardware limitations because it depends on system frequency and internal prescaler. For Hexiwear device, max PWM period settable is 139 ms.

Hope this can help you :slight_smile: