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.

This issue is apparent when trying to set the period words (0x828 and 0x82C) to 0xFFFFFFFF or anything greater than 0x7F7F7F7F for that matter.