Ok we finally got the code working. This picture explains it much better. The yellow trace is a 1.5Khz square wave. The purple and green traces are the resulting outputs.
Code:@ __CONFIG _INTOSCIO & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _BOD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF DEFINE OSC 8 ' Internal 8MHz CMCON0 = 7 'Comparators off ADCON0 = %00000000 'ADC enabled and right justified ANSEL = %00000000 'GPIO.0 and GPIO.1 analog input INTCON = 0 'INTERRUPTS off OSCCON = %01110000 '8 Mhz TRISIO = %000100 'GPIO2 input GPIO = %00000100 'All outputs = 0 on boot OPTION_REG = %00101000 ' INCLUDE "Modedefs.bas" A VAR word A=0 TMR0= 0 input GPIO.2 main: while TMR0 <= 5 wend A = A+1 TMR0= 0 if A <> 5 then pulsout GPIO.5, 400 if A=5 then onepulse 'TMR0= 0 pause gosub main onepulse: TMR0= 0 pulsout GPIO.4, 400 A=0 gosub main




Bookmarks