using wait-for-interrupt for delay and fixed an endless loop condition after 16.384 seconds
using defines for base pointers