> I worked with 68332 and it generates this exception.
Me too.
Do you NEED to trap bad addresses? There are only so many points in your code where it should be possible to generate a "bad pointer" and you could add explicit tests (for null pointers etc) before dereferencing them.
It is nice when the CPU can trap these bugs and print on the console (usually) where it was when you made the mistake, but the chip makers don't seem to talk to the programmers any more. All you're left with is programming the Watchdog to reset the CPU out of these situations, and "the watchdog doesn't leave any tooth marks". What was a 1 minute fix can now take a week adding breakpoints or print statements, trying to home in on the bug.
Being able to debug your code should be part of the CPU silection, If it doesn't support trapping bad addresses, don't use the chip.
> I have started to read MMU and probably it will be my solution,
MMUs are big and ugly, and you don't want the complexity unless you really have to, or unless the CPU forces you to. For instance the MPC series doesn't provide any way to have cached and uncached memory (the IO registers) without turning the MMU on. The MMU handling code in the product I worked on took over a YEAR to get working properly!
The MMU needs a table describing all of your memory, and then SOFTWARE has to handle the traps and reload
the TLBs. It isn't simple. On some CPUs the debug registers can be pressed into service to trap accesses in certain ranges. See if they're flexible ebough on your CPU.to trap "access between end-of-ram and start-of-io-page" for instance.
> Does anyone know were can I find any example to work with MMU or more documentation?
Linux, but that is extremely complicated and anything but clear.
Tom