Hi Tong,
Again, I don't see any problem with your code, which makes me suspect that the problem happens because of the way the system is responding to your code.
What exactly do you mean by 'bus error' and 'overflow'? Are you seeing errors output on the console?
You can eliminate any problems from the ISRs, or the way that your IRQs have been set up by commenting out all of the calls to mcf5xxx_set_handler() in main(). Also remove the __interrupt__ modifier from your ISRs. Now add a few lines to main which will call the different handlers like so:
Code:// Insert this before the while loop in main()button_down();// Pause 1 sec (not required if you step through with the debugger)cpu_pause(1000000);button_down();cpu_pause(1000000);// and so on.
This will allow you to test your ISRs without having the interrupts set up. If the handlers now work properly then you must suspect that the IRQs are not properly configured. You can either fix this or change to poll the port.
If this code also fails, then I suggest that you remove the code that initialises gpio, lcd, etc., step by step, until the switch statement works. You may also need to comment out code from the write() function if your lcd is not initialised. When the switch statement is working, add the code back line by line until it fails again - you should then find out what is causing the problem.
Paul.