100KHz Square Wave generator using PIC16C84
Following on from the LED flasher circuit, we can reduce the delay in the loop to 10uS (10 microseconds) and produce a 100Khz square wave.
Given a 4 Mhz PIC 16C84, the program below will generate a 100Khz square wave on PORTA bit 0 (i.e. pin 17). This little program is useful for testing oscilloscopes (though it is not very accurate).
This program is available as:
; Mark Crosbie 9/12/98 ; Scope test program. Generate a 100Khz square wave. ; ; The Program simply sets up Bit 0 of Port "A" to Output and then ; loops, setting the value alternatively low and high ; ; Hardware Notes: ; Reset is tied through a 4.7K Resistor to Vcc and PWRT is Enabled ; A 220 Ohm Resistor and LED is attached to PORTA.0 and Vcc ; ; device pic16c84 include "p16c84.h" __CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON ; Mainline of FlashFast org 0 clrf PORTA ; Clear all the Bits in Port "a" clrf STATUS bsf STATUS, RP0 ; Goto Bank 1 to set Port Direction bcf TRISA, 0 ; Set RA0 to Output bcf STATUS, RP0 ; Go back to Bank 0 Loop movlw 1 ; Turn on the LED on Port A movwf PORTA ; movlw 5 call mdelay ; 5 uS delay movlw 0 ; Turn off the LED on Port A movwf PORTA ; movlw 5 call mdelay ; 5uS delay goto Loop ; counter variables
For more detail: 100KHz Square Wave generator using PIC16C84
For All Your PCB Need, One-stop PCB Solution Services Appear:
EasyEDA: free PCB design tool, 200,000+ engineers are using
PCBs: 10pcs 2-layer 10x10cm only $8.21, on-time global shipping
Components: save 50% on cost, save on freight if shipped with ordered PCBs
Current Project / Post can also be found using:
- square wave generator using pic microcontroller
- square wave generation using pic 16f877
- square wave generator using pic
- assembly codes for PIC16F877 to generate ta square wave