I don't like the variable name counter because it does not describe what it does.

I also suspect that you don't have to set this here, and can wait until you get an overflow event.