I think that this is a hardware question? So here goes:
The attached is a schematic for a data logger that I have built. In (most) cases it works as I would wish.
However (isn't there always!), when I insert my micro SD card, the ATMega reboots. Not what I would wish.
My first thoughts were Brownout? As the supply voltage drops as the card is powered up. Scoping the supplies (3v3 & 5v) shows no problems that I can detect. And bunging in larger & larger capacitors on the supply line have no effect.
I also understand that the SD Cards IO are tri-state until CS is activated and I can't see any disturbance on them as I insert the card..
I read various comments on the requirement for pull-up resistors on the control lines but I think the consensus is "Not needed". I also see designs with HC4050's as level shifters But this design is all 3v3 (except for the I2C display).
Any thoughts or comment will be most welcome.
I also understand that the SD Cards IO are tri-state until CS is activated
This may not be true. ..
Try 'insert card' routine with MO/MI disconnected
Try some buffer chip. 74HC125, 74HC244, 74HC245 etc.