void freq(char pins, unsigned int frqcy, unsigned int timer) // Frequency Function using Timer1 (16-Bit)
{
unsigned int times;
TMR1IF = 0; // Clear OVF Flag
GPIO = pins; // Initialize GPIO
for(times=timer;times>0;times--) // Duration of playing
{
TMR1H = (frqcy >> 8) & 0xFF; //Load TMR0H byte first
TMR1L = frqcy & 0xFF; // Load TMR0L byte next
while(!TMR1IF); // Wait for timer
TMR1IF = 0; // Clear OVF Flag
GPIO = ~GPIO; // Invert output
}
TMR1IF = 0; // Clear OVF Flag
}
This will depend on your cpu clock speed. The most common is to use Timer1 for this purpose. And a clock crystal. Will you be using interrupts?Guys,
Any 1 hv ideas how to use Timer2 as counter to count the value of 1second. Cause i need the microcontroller PIC16F877A to interface with LCD to display current time in the form of
HH:MM:SS AM/PM.
Please kindly share your ideas.
by Jake Hertz
by Aaron Carman
by Aaron Carman