Hi,
I made a custom Microcontroller Board using the AtsamD21G18A and I am having some problems with it.
After unsuccessfully trying to connect to an I2C device on board, I was recommended to try to run an I2C scanner first. This is the one I used: https://randomnerdtutorials.com/esp32-i2c-scanner-arduino/
Of course I adjusted the Wire.begin() function to the required pins, which are 13 for SDA and 14 for SCL.
Everytime I try to run this specifc sketch, it seems corrupt the bootloader on the chip, meaning I can‘t connect to it and have to re-burn the bootloader everytime.
After lots of debugging together with a friend, we found out, that it probably comes down to the Wire.endTransmission() function. The way we found this out, is by commenting specific parts of the code out, trying it out and repeating (definitely not the most efficient method, we know).
I know that there could be a lot of reasons for this, so let’s try to single them out.
I am happy to share any further Information or Files if necessary.
Thanks, hytralium
Maybe it is that thing over there messing with this thing here. You need to post an annotated schematic showing exactly how it is wired, be sure to include all connections, power, ground, power sources. Also links to technical information on the parts will help.
My first question would be, did your code run on a SAMD21 development board? If yes then we would first consider a hardware issue.
If this is a hardware issue it would be good to know your experience making custom processor boards. This is only to not waste anyone's time if you are already proficient. If not we need to see the schematic and board layout.
I have attached the schematic now.
Unfortunately, I have no way of knowing if it “would“ run, because I don’t have any ARM development board.
This is the first microcontroller I have produced, but I made sure to listen to all the datasheets. Also, I redesigned the entire thing about 3 times over before manufacturing it, to make sure everything was correct.
The values of the resistors are not in the schematic.
The green and blue leds are missing resistors.
It is better to have a resistor to the buzzer, because when it is a piezo buzzer, then it acts as a capacitor.
A pullup resistor for RX will keep the signal high (and idle) if nothing is connected.
markd833: I have not set a fuse to my knowledge, I am going to have to do some research on how to do it.
Koepel: I was already pointed some of these things out, though know that I think about it, I should’ve probably done this before ordering these boards…
It likely won't fix your problem, but setting the fuses will protect the bootloader from being overwritten and eliminate one step.
One other observation, and I may be wrong here, but there don't seem to be many decoupling capacitors. Others with more knowledge of bare SAMD21s will hopefully step in advise.
I agree and I did not see any bulk capacitors. Assuming you have not had the board made add about 6 47uF caps, one for each motor, 1 for the radio and 2 for onboard. More would not hurt. I would also be sure you have either a 220nF or a 100Nf with each of those. Other values will work but I chose these values because that is what I have in SMD. Anything above 47uF is much harder to come by for me.
I would recommend getting an Arduino with the same processor to get started, that will give you something known good to start with.
Thanks for sending this article, even though hasn't worked, I still learned a lot from it.
I have realised, that Wire.available() doesn't even true return, so it has to be something, before Wire.begin().
Maybe it is because Sercom0 is already used for something else.
Except for that, I am kind of out of ideas... I don't know what to do from here.
Looking at TrajectoryR3.pdf, you have PS tied to ground. This selects the SPI port, not the I2C port for the Gyro.
Beyond that, looking at how Address bit 0 is set via the SDO lines. The data sheet does not refer to any internal pull ups, and you have SDO0 and SDO1 as NC, so you have an undefined address for each I2C target in the device. (section 6.2 and Table 14 )
As for CSB1, that switches the mode of the Accel from I2C to SPI. (section 6.1). I see also that the CSB lines have internal pull ups, and you have the external pin as a NC. I think you might actually be accidentally flipping the Accel portion into SPI from its default config. It does say though that a change occurs at a rising edge, and suggests VDDIO or DNC in table 14, which is what you did.
Have a look at Figs 8 & 9, and see if they help.
This isn't the easiest of datasheets to read. It looks like two devices in one package, those always have quirky interfaces. Good luck with the board bring-up.