As Marek has already mentioned, for the trim value to work correctly, two things must happen:
1. Your programming tool calculates a trim value and stores it in the appropriate Flash location during loading of your application into Flash.
2. Your code actually copies the trim value from its non-volatile location to the related register during soon after reset (i.e., before you need to depend on this frequency being accurate enough).
If both of these steps are correctly performed, and you're still having problems, then most likely your assumption about the trimmed bus frequency is wrong. How could this happen? For example, P&E programming algorithms use a default bus frequency for each MCU variant. If your app uses a different one (which in my experience is very common), you need to also adjust the related programming algorithm so that the trim value is calculated correctly. (How to do that is a different matter as there is not clear documentation on this, at least with older versions of their software. But if this is the problem you're having, ask again.)
A USBDM-based programmer, on the other hand, will allow you to set the trim frequency directly.