Blinking an LED as a function of signal frequency
My guess to your problem is that your problem is with the data type being used for the attributes of the delay function.
When you are using 'integer' as the attribute data type, you can't express values less than 1 but greater than 0. If your frequency is greater than 1000, the code won't work. you need to manipulate the frequency variable in such a way that the division won't go below 1 but will still be related to frequency. Try dividing frequency with a constant.