Actually STM32F1xx has only 16-bit timers. But there is quite easy way to overcome that limitation. I have done it like this:
void getCount()
{
int16_t now = TIM3->CNT;
int16_t delta = now - oldcount;
oldcount = now; //oldcount is volatile int16_t global variable
count += delta; //count is volatile int32_t global variable
}
As you can see, here a difference between current value and the previous value is calculated and this is added to the 32-bit count-variable. Now you only have to make sure that the getCount function is called often enough that the actual 16-bit counter doesn't go more than 32k (15bit) steps between calls. So basically you call it in your PID loop and it works fine.
Pekka