I've had similar problems resulting from the fact that my K10D and 540 flash don't seem to fit together very snugly. I'm not sure which is at fault, but I suspect the flash. I have two 360 flashes which both fit well, as well as other hot shoe mounts which the 540 fits snugly on, but I did have the same problem with my 540 flash being lose on my K100D. I'm sure they'd fix it if I could find time to send it in... one year is up in May, so I've got to do it soon.
Anyways, the problem comes from the flash sliding back in the shoe ever so slightly that it still touches the main contact, but not the Pentax specific contacts. Doing this causes the flash to act as a manual flash, and will fully discharge the flash each time. for a quick fix if this sounds like the problem, get some small white plain labels and cut them in half. About three stacked together will increase the thickness of the hotshoe enough that the flash will tighten better, though it can still slide if you're moving alot.
The better answer is just to send the flash in to be repaired, so that it will tighten completely to the camera.... but who has time to wait when you're making money with it? Can't stop eating for 4-5 weeks!