code stopps after using a function

You shouldn't be using it in an interrupt