Return to SDK Examples for Microchip Studio
46#define motor ConnectorM0
52#define SerialPort ConnectorUsb
57 motor.HlfbMode(MotorDriver::HLFB_MODE_HAS_BIPOLAR_PWM);
59 motor.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
63 SerialPort.Mode(Connector::USB_CDC);
64 SerialPort.Speed(baudRate);
65 uint32_t timeout = 5000;
67 SerialPort.PortOpen();
68 while (!SerialPort &&
Milliseconds() - startTime < timeout) {
73 SerialPort.Send(
"HLFB state: ");
76 MotorDriver::HlfbStates hlfbState = motor.HlfbState();
79 if (hlfbState == MotorDriver::HLFB_HAS_MEASUREMENT) {
81 SerialPort.Send(int8_t(round(motor.HlfbPercent())));
82 SerialPort.SendLine(
"% torque");
84 else if (hlfbState == MotorDriver::HLFB_ASSERTED) {
87 SerialPort.SendLine(
"ASSERTED");
90 SerialPort.SendLine(
"DISABLED or SHUTDOWN");
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287
uint32_t Milliseconds(void)
Number of milliseconds since the ClearCore was initialized.