Blinking LED code at a particular frequency I wrote a function for interacting with my PIC16F1788. The code sends pulses out the RC4 port at a specific frequency, to make an LED blink according to that frequency. So the LED will blink faster or slower depending on the magnitude of the frequency. I decided to take a blinking code and vary the delay time according to my input frequency as follows. 

void blink(int frequency){
/* starts the LED blinking at a particular frequency */

while(1)
{ 
 PORTCbits.RC4=0XFF;  // RC4 on
 __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
 PORTcbits.RC4=0X00;   // RC4 off
 __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
}



}


would this code work, is this a good idea ,and is there anyway that I could improve it?
Your code: 

void fault_blink(int frequency){
/* starts the LED blinking at a particular frequency */

while(1)
{ 
 PORTCbits.RC4=0XFF;  // RC4 on
 __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
 PORTcbits.RC4=0X00;   // RC4 off
 __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
}
}


Indentation

The body of the fault_blink function should be indented, along with the body of the while loop.

The code now:

void fault_blink(int frequency){
/* starts the LED blinking at a particular frequency */

    while(1)
    { 
         PORTCbits.RC4=0XFF;  // RC4 on
         __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
         PORTcbits.RC4=0X00;   // RC4 off
         __delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
    }
}


Spacing

To enhance readability, there should be spaces around arithmetic operators and = signs.

The code now:

void fault_blink(int frequency) {
/* starts the LED blinking at a particular frequency */

    while(1)
    { 
         PORTCbits.RC4 = 0XFF;  // RC4 on
         __delay_ms(1000 / frequency);   // time in ms dealing with frequency values in kHz
         PORTcbits.RC4 = 0X00;   // RC4 off
         __delay_ms(1000 / frequency);   // time in ms dealing with frequency values in kHz
    }
}


0X vs 0x

This isn't the biggest thing, but most people have a lower-case 'x' when defining a number as a hexadecimal number.

The code now:

void fault_blink(int frequency) {
/* starts the LED blinking at a particular frequency */

    while(1)
    { 
         PORTCbits.RC4 = 0xFF;  // RC4 on
         __delay_ms(1000 / frequency);   // time in ms dealing with frequency values in kHz
         PORTcbits.RC4 = 0x00;   // RC4 off
         __delay_ms(1000 / frequency);   // time in ms dealing with frequency values in kHz
    }
}


Unnecessary comments

Don't repeat your comments; especially when the original comment is very near.

In this part of your code:

PORTCbits.RC4=0XFF;  // RC4 on
__delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz
PORTcbits.RC4=0X00;   // RC4 off
__delay_ms(1000/frequency);   // time in ms dealing with frequency values in kHz


You can remove the comment on the second __delay_ms call as the comment is identical to the call right above it.