This is very helpful.
http://www.picbasic.co.uk/forum/cont....-PICMultiCalc
Probably the easiest way to get started is with ON INTERRUPT. It is not the most accurate, it will only interrupt when nothing else is going on. Sound silly but..
An example would be a long PAUSE, the ON INTERRUPT will flag and run when the PAUSE is finished. ASM interrupts or DT's instant interrupts will work as true interrupts, but for your case ON INTERRUPT should be close enough.
This should be close. Run it on your board and see what happens.
Code:
'FL PIC16F887
'16F887 INT RUPT
'44 PIN DEMO BOARD
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
INTCON.5 = 1
OSCCON = %01110000 '8 Mhz
DEFINE OSC 8
OPTION_REG = %01000111 ' 1:256 PRESCALE
ON INTERRUPT GOTO TLOOP
CNT VAR BYTE
D VAR BYTE
D = 0
DATA @10,10,20,30
TCNT VAR BYTE
START:
FOR CNT = 0 TO 150
PWM PORTD.7,D,10
D = D + 2
NEXT CNT
GOTO START
DISABLE
TLOOP:
TCNT = TCNT + 1
INTCON.2=0
IF TCNT = 8 THEN
TOGGLE PORTD.4
TCNT = 0
ENDIF
RESUME
ENABLE
Bookmarks