Fixed issue with timer period

Two issues resulted in unexpected handling of timer period.
1. When converting byte array to long, bytes were typecast to longs
which resulted in sign extension if the MSB was a 1. Solved by ANDing
long with 0xFF.
2. To check if the timer was finished, it was checking if count was
greater than zero which was false if the MSB was 1. Changed to !=
comparison which is safe because the enclosed decrement is the only way
count is decremented.
Merge pull request #1 from jmc734/master

Fixed issue with timer period