bitfasching / AS5601

Library for driving the sensor AS5601 over I²C on an Arduino
Other
16 stars 6 forks source link

Unfunctional code while using the library #4

Open T4psi opened 2 years ago

T4psi commented 2 years ago

Hi!

Recently I was trying to connect to several AS5601 ICs with I2C communication using your library for Arduino. Unfortunatelly, I noticed that after uploading the sample code, nothing would appear on the serial monitor, not even the initial "Angle Measurement with AS5601" text. I have tried the same code excluding the lines that depends on the AS5601 library (so basically simple serial prints remained) and everything works as expected. I tried to upload the code to an MKRZERO and also to a DUE, but neither of them would work. What is more, it seems like the sample code bricks the MKRZERO as Windows wouldn't recognize normally the board after the code was uploded (there is no USB connection sound). I also tried if the ICs work on their default encoder pins, and they do give proper signal. Do you have any idea what could go wrong?

Thank you in advance!

bitfasching commented 1 year ago

Hey @T4psi,

sorry for getting back so late, I haven't email notifications enabled.

The library is intended to be used with traditional Arduino targets using ATmega microcontrollers (at least this is what I meant by on an Arduino). I don't know the MKRZERO, it seems to be using an ARM Cortex M0. The AS5601 library doesn't actually care about the microcontroller though and relies on abstractions in Arduino.h and Wire.h – maybe these core libraries somehow behave differently on the MKRZERO? You could specifically search for differences in the TwoWire implementations between the ATmega family and your board. I would expect errors at compile time though. Can you enable verbose logging for both compilation and upload in the Arduino IDE (if this is what you're using) and post the log?

Regarding the other issue, I can't imagine how the sample code could brick a microcontroller. Could it be that something is fundamentally going wrong when you flash code onto the device? Again, I don't know the MKRZERO, but if the controller doesn't interface the way it did before, I'd look for a messed up bootloader or wrong fuse bits.

Cheers, Nick