Finally, the SRF04 is now interfaced and working with my Renesas M16C SKP. As previously stated, I ended up needing to use one of the INT (interrupt) pins, along with one timer, and one GPIO. I really didn't want to use up that INT pin, hoping instead to use if for other things like kill switches,etc, but maybe losing one is ok. I think my previous design, that used one timer (including it's I/O pin) in both timer mode and pulse width measurement mode, was more elegant, and I may revisit it in the future. In the end, doing it this way turned out to be a bit simpler. I need to remember to learn to walk first...
I still have one issue with the state machine not behaving exactly as expected but it is of little importance as the additional state was really there for completeness and is not really currently required.
So, I now have a totally interrupt driven SRF04 interface - all you need to do is call srf_trigger(), and at some later stage call get_srf_reading_mm(). It's non-blocking, and pretty flexible.
Now to integrate it with the robot.