Author Topic: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)  (Read 694 times)

0 Members and 1 Guest are viewing this topic.

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« on: October 02, 2019, 07:09:07 pm »
Howdy,

I have custom PCB design with SAMD21G and 2 separate I2C (feather M0 bootloader).

I wrote  code to scan both I2C lanes and uploaded to MCU  – second I2C port (that I created) scan finds chips just find, but no devices on 1st I2C port (there are 3 devices with different addresses on that port). I also used default I2C scanner code that scans only default I2C port – same result, no devices.
And here is the interesting part – If I connect another I2C device with its own pullups – ALL devices just appears in the scan until I disconnect it and they disappear again. You may say it's pullups, well, just keep reading....
I have another SAMD21G bare breakout board with only necessary components, if I jumpwire it to the same I2C lanes (with pullups only on custom PCB) and scan – it detects those devices just fine (with no additional I2C device and no extra pullups). Pullups on that line works fine, I used 10K resistors pull to 3,3V.

Also that SAMD21G on the PCB doen't react to RESET going low (internally pulled up), at least computer doesn't make USB connect/disconnect sound (other SAMD21G break out board do).

I'm thinking this is cos of one of two things:
1. some SAMD21G pins are pulled up/down by the PCB design that shouldn't be and messes with reset
2. I did an oopsie on PCB design – one chip (on 2nd I2C port that works) uses interrupt pin, and I missed that this chip sends 5V instead of 3,3, so that MCU got 5V. After realizing this I disconnected that pin and tested – that interrupt pin on MCU seems to work fine still.

Eventually I will solder jump wires and connect pin by pin to breakout board to find out what is the issue, but as you can imagine it's very tedious task, so I just posting my issues in hope to get some ideas before I do that. Sadly I just can't change MCU – I don't have hot air station.

I little update: I figure I'll try to add another I2C device (with no pullups on it this time, pullups only on PCB), and "bad" MCU on the chip sees it, but this time it detects only that chip, it doesn't detects other 3 chips on the PCB. I tried again another I2C device with its own pullups – all chips gets detected. WTH...  :o

Cheers

« Last Edit: October 02, 2019, 08:00:55 pm by 3dgeo »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #1 on: October 02, 2019, 09:05:52 pm »
Without looking at the actual I2C signals with a scope it would be impossible to tell what is going on exactly.

Same for reset. Check that the line actually goes low. I'm not really sure what you can really do to make it not go low short of connecting the reset pin directly to the supply voltage.
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #2 on: October 03, 2019, 12:30:53 am »
It's actually 2nd version of this PCB, on a first version this I2C works fine (no changes between V1 and V2 in this I2C). And reset pin is connected only to testing pad so I could manually reset MCU if needed. I'm using Adafruit bootloader, so to enter programming mode I have to double tap reset pin, and with minimum config breakout of SAMD21G this works just fine, but with custom PCB I have to disconnect and reconnect power, then double tap reset pin, only then it enters programming mode. I think easiest way would be to populate another PCB and test it after soldering every component until I found the problem.

I have logic analyzer, will poke around tomorrow.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #3 on: October 03, 2019, 01:10:30 am »
Is it possible that some code changes reset to be a regular GPIO pin? May be by accident?
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #4 on: October 03, 2019, 02:16:46 am »
Is it possible that some code changes reset to be a regular GPIO pin? May be by accident?

I didn't mess with the fuses myself, but now as you mentioned – Atmel Studio could change them while burning bootloader. Tho I burned same bootloader to both SAMD chips so both chips reset should be messed up. Maybe that bootloader looks at specific pins states while IC  powers on and sets something accordingly...
Anyway, thank you, that was a good hint – I'll burn Arduino Zero bootloader and check I2C and reset pin. 

Update on the progress tomorrow :-+
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #5 on: October 03, 2019, 02:18:22 am »
Pins are not configured though the fuses. Even regular code can change the pin function in run-time.
Alex
 

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #6 on: October 03, 2019, 03:14:03 am »
According to datasheet Reset pin do not have Port or Port pin number, so I'm pretty sure it's not possible to make Reset pin as a regular pin via code. Code I uploaded is very simple, it's very unlikely I changed something that I shouldn't.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #7 on: October 03, 2019, 03:17:19 am »
My bad. It is a dedicated pin indeed on this device. I guess they though that there are enough I/O pins already.

In that case only looking at the board with a scope/logic analyzer may reveal something useful.
Alex
 

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #8 on: October 03, 2019, 08:27:22 pm »
I think my board is possessed...  |O

After some time when plugging USB all I got is "device not recognized", I nuked that MCU and changed with new one, same, now I know for sure pins are messing stuff up. Will solder another PCB component by component and test on every step.

Also I noticed my Pfets are not working properly, I used SQ3985EV, added 3.3V pullups on Gates, 5V on Source, Drain should be 0v with pullups, but no, it's 5V  :wtf:
PCB design and schematic looks correct...  :-//

P.S. burning Arduino Zero bootloader did not helped, Reset pin still seems to brick MCU instead of resetting it.
 

Offline maginnovision

  • Super Contributor
  • ***
  • Posts: 1288
  • Country: us
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #9 on: October 03, 2019, 09:06:58 pm »

PCB design and schematic looks correct...  :-//

Did you want help? I haven't seen schematic, board layout, code, or pictures of anything.
 

Offline Kasper

  • Regular Contributor
  • *
  • Posts: 210
  • Country: ca
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #10 on: October 03, 2019, 09:16:39 pm »

Also I noticed my Pfets are not working properly, I used SQ3985EV, added 3.3V pullups on Gates, 5V on Source, Drain should be 0v with pullups, but no, it's 5V 

On front page of your PMOS datasheet:
If Vgs = -1.8V then Rds = 0.3ohms

For your description:
Vgs = Vg - Vs
Vgs = 3.3V - 5V
Vgs = -1.7V

Rds ~ 0.3ohms

Sounds like your PMOS circuit is working. Just not how you expected.  Generally gate voltage should be as high as source voltage to ~fully turn off PMOS.

When switching PMOS with low voltage MCU it can help to connect NPN or NMOS between MCU and PMOS.

 
The following users thanked this post: 3dgeo

Offline Kasper

  • Regular Contributor
  • *
  • Posts: 210
  • Country: ca
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #11 on: October 03, 2019, 09:21:50 pm »

Also that SAMD21G on the PCB doen't react to RESET going low (internally pulled up), at least computer doesn't make USB connect/disconnect sound (other SAMD21G break out board do).

I'm thinking this is cos of one of two things:
1. some SAMD21G pins are pulled up/down by the PCB design that shouldn't be and messes with reset

This video might help with this:

EEVblog #831 - Power A Micro With No Power Pin!
YouTube · EEVblog
Dec 17, 2015
 

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #12 on: October 04, 2019, 09:00:37 pm »
Sounds like your PMOS circuit is working. Just not how you expected.  Generally gate voltage should be as high as source voltage to ~fully turn off PMOS.

Thank you for explanation, I'm not that familiar with Pfets.

EEVblog #831 - Power A Micro With No Power Pin!
YouTube · EEVblog
Dec 17, 2015

I encountered issue in the video with 74 logic, this is not the case. I should clear it out – pulling Reset to ground seems to crash MCU, it stops responding (at least serial com to PC stops).

I build two more PCBs with minimum components – first one had 5V to 3.3V step down, it worked at the beginning, but then it just stopped, I can't even get it recognized with Atmel Ice. Also I notices that Voltage sometimes goes down to 0 on USB 5V rail on that board, so I figured it's regulator (MCP1700 SOT-23). So I just made another PCB with no regulator, it as well not recognized with Atmel Ice (it's not the Ice cos it still detects my first PCB just fine).

I didn't post the schematic and PCB layout cos I wasn't near my workstation were I can prepare this info.
But I guess I'll have to do it now cos even cursing and threatening at this PCB doesn't seems to work.  :horse:
 

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #13 on: October 05, 2019, 06:38:33 pm »
OK, I'm back with the schematic, at least part of it that I'm having issues.

By making image below I realized that I'm using 12pF crystal caps (C52,C53) instead of 15pF, can this be a problem? Crystal I'm using is 32.768KHz +-10ppm, 12.5pF.

Also I think I found my problem with the I2C – I'm using MCU IO pin PA21 to reset 3 ICs (NOT THE MCU) on the same I2C  bus I'm having problem with. I actually made some tests before to make sure this pin works properly, it seems at that time that it's fine. This PA21 pin name seemed very familiar tho but I didn't know why. I think that SAM-BA bootloader uses it for some sort of data representation LED, I assume it's the same with Arduino core, so MCU toggling that pin. Me adding another I2C device with its own pullups reduced resistance and that line didn't get to 0v or wasn't long enough on 0V to reset those chips, that's why all IC showed up on the scan script, but If I added another chip without its own pullups only that chip gets detected cos other chips are in Reset constantly – now that's an interesting issue.... I think I'm lucky to figure this one out  :box:

I'm guessing Reset issues I'm having is also related to my PCB pin configuration.
To fix Pfets I'll probably will add ULN2003 darlington array, it got 7 drivers, 7 drivers I need. If anyone have better idea – let me know.

Now I need to find out why my other PCBs with minimum config doesn't work, crystal/caps? But Atmel Ice should be able to detect those with no crystal at all... I really doubt I fried chips while soldering, ESD maybe?

I removed GND copper fills, so please ignore GND:
« Last Edit: October 05, 2019, 06:52:51 pm by 3dgeo »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #14 on: October 05, 2019, 06:43:23 pm »
Crystals are not likely to be the problem.

I don't know anything about SAM-BA or Arduino bootloaders, so can't help you here.

Again scope or logic analyzer will answer those questions.
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #15 on: October 05, 2019, 07:19:26 pm »
What bootloader do you know/use?
I think eventually I will have to write my own, if I manage to beat that steep learning curve that is...
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #16 on: October 05, 2019, 07:25:11 pm »
I write my own. There is no real learning curve. Bootloaders are easy unless you want to make them complicated.

Here is example of a USB HID bootloader https://github.com/ataradov/bootloaders

Attached is a simple UART bootloader for SAM D21.
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #17 on: October 05, 2019, 08:13:13 pm »
I'm very grateful, Alex, thank you for your help (this is not the first time you are helping).

I actually tried to find info on this topic, and your name came up, so I know you are THE MAN on these things, and I know it's easy for you but definitely not for me. Tho I'm getting there, slowly, maybe a bit frustrated at the time but I'm moving :)

What do you mean by "USB HID bootloader"? Why I should need HID on bootloader? As far as I understand HID should be enabled when main program runs, or I'm wrong?

My end goal is this:
"firmware" on MCU is running as normal, it gets serial command that there is a need for firmware update, "firmware" changes "firmware update is active" "fuse" and resets MCU.
Bootloader starts and stays in bootloader mode if "firmware update is active" (I still don't know how it should be done, I found other uses flash memory location to read/write this state, in my circuit there is external I2C EEPROM that can be used for this purpose as well).
Bootloader should be able to receive commands/data via USB (serial com) and update "firmware", deactivate "firmware update is active" and reset itself or reset itself if commend received to do so via serial com.
"Firmware" should be able to emulate HID keyboard and use serial port at the same time (same USB).

For me it's a huge goal to do this without Arduino existing libraries...

How much a bootloader like this could cost? 3-4-5 figures?
« Last Edit: October 05, 2019, 08:15:22 pm by 3dgeo »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #18 on: October 05, 2019, 08:20:25 pm »
HID is the easiest way to make a device work 9n all OSes without drivers.

What you are describing is exactly what my HID bootloader is doing.
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #19 on: October 05, 2019, 08:51:01 pm »
But this will not work with Ardino IDE I'm guessing?
As I said – I don't know how to make HID keyboard without Arduino libraries, it's too big of a gap to jump, at least for now.

Tho I would like to know what is the best IDE for ARM developing in general? I have Atmel studio, but will it work with STM32?
When I migrate I want to have one IDE (industry standard) for all ARM chips.

Also, is there some sort of "starter code" generator for SAMD chips like STcube for STM chips?

Sorry if I'm asking stupid things, I'm in uncharted waters here :)
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #20 on: October 05, 2019, 09:00:08 pm »
No, none of my stuff would work with Arduino.

AS will not work with STM32. Something Eclipse-based will be your only option for a full-featured IDE.  But I have no idea how easy it is to setup nowadays, I have never used IDEs.

https://start.atmel.com is a starter code generator. If you want less bloat, you can have a look at my starter projects https://github.com/ataradov/mcu-starter-projects
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #21 on: October 05, 2019, 09:25:37 pm »
Wow, that's cool, I didn't knew I could get example codes so easily  :-+

I found USB composite right a way, this is awesome, you should lead with this link next time  ;D

This is exiting, now I can think about migrating from Arduino :)

Thanks again, Alex!
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #22 on: October 05, 2019, 09:28:03 pm »
If you want to see an actually easy to understand VCP implementation, then I have one too - https://github.com/ataradov/vcp
Alex
 
The following users thanked this post: 3dgeo

Offline 3dgeo

  • Regular Contributor
  • *
  • Posts: 213
  • Country: au
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #23 on: October 05, 2019, 09:40:51 pm »
Thanks, I'll take a look.

For now I need working USB composite lib that I can modify, I need "send key press" function and "send serial" function or similar  :-DD
I hope this example I found will give me that.

You wrote you never used IDE, how you code than? What tools do you use for that?


 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6012
  • Country: us
    • Personal site
Re: One crazy SAMD21G MCU – I2C/RESET issues (custom PCB design)
« Reply #24 on: October 05, 2019, 09:54:23 pm »
For now I need working USB composite lib that I can modify, I need "send key press" function and "send serial" function or similar  :-DD
I hope this example I found will give me that.
Here is another example of a composite device HID/VCP  - https://github.com/ataradov/free-dap/tree/master/platform/samd11_vcp . It does not implement actual HID devices. HID is just used as a driverless way to communicate with devices.

You wrote you never used IDE, how you code than? What tools do you use for that?
Text editor and makefiles.
Alex
 
The following users thanked this post: 3dgeo


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf