Wednesday, January 6, 2021

PIC16F887 Timer0 Creating Delay Function in MikroC

Introduction

In previous post of Timer0 interrupt programming, we use its interrupt advantage to create a timer tick in a range of milli second. We can decorate some more features over this capability.

A precise timing delay function can be created using timer0 interrupt programming. In this example we create a delay function from the existing 1ms-delay routine that it was written in previous example

PIC16F887 Timer0 Creating Delay Function in MikroC
Program simulation sample

 

Programming

Delay function created by adding more routine that rely on free running counter in the ISR coding of Timer0 interrupt.

void ms_delay(unsigned count) {
     while(ms_count<count);
      ms_count=0;

}

There is no change in source code but it excepts only one additional routine that handle timing delay. 

PIC16F887 Timer0 Creating Delay Function in MikroC
Schematic Diagram

Program in MikroC



Click here to download source file.


 

No comments:

Post a Comment

Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)