First of all, check to see if there's some sort of error code that displays along with it. It should display a nintendo support website along with it. enter that error code in the designated search bar, and it should tell you what the problem is and if it's a small problem, how to fix it.
If no error code pops up, disregard all that, but instead, try replacing one of the 2 DSes, and see if the error still occurs. If the error still occurs, try replacing the other DS. And If that doesn't work, try using a different Gen IV or Gen V cartridge.
This may sound like a lot to have off hand, but maybe you could borrow another DS or cartridge from a friend if you lack any of these extra materials.
Tell me if any of these methods solved the problem.