Sorry I missed the distinction between window size and sampling rate so it can't go away.

It should also be *portTICK_RATE_MS I think.  That is incorrect in a lot of the code (but since it's 1 doesn't influence things).

Also this should probably come after hte downsampling since with the way it is now this might end up interrupting some of the downsampling and cause you to have a buffer that is 

[data data data pause pause pause data data data]

which will produce weird frequenceis