Pulses are very useful for a number of things and there are a number of ways to produce the output. The simplest means of generating a square wave pulse output is to toggle a digital output on and off for a set period of time. This would be a duty cycle of sorts with an on and off period so its similar to pulse width modulation, you are just not using the CCP module.

Let’s say for example you need to produce a signal with a frequency of 50 HZ i.e. the LED will flash 50 times a second. Granted this will flash faster than the human eye can perceive, but if you have an oscilloscope you will be able to see the waveform.

So the maths:
f = 50Hz
t = 1/50
t = 0,02 s or 20 mS

What we have with 20 ms, if the duty cycle or the full period for which the pulse is both on an off.

The code to produce the pulse waveform is shown below, and the mark to space ration can be adjusted. For example if the ratio needed to be adjusted the total time should not exceed 20 ms and this will retain the 50 Hz.

void toggle()

void main() {

  ANSELB = 0x00;
  TRISB = 0b00000000;   // PORTB All Outputs
  TRISA = 0b00001100;   // RB.B1 Toggles
  do {
  } while(1);