Hello dave
Ok, I found all my files I need however I am using PicBasic Pro Compiler Ver. 2.46. (I'm one of those poor saps that lost his receipt and cannot upgrade.)
When I compile it works but trying to build using MPLAB I get a masive amount of errors. Here is the code.
************************************************** **************
'* Name : UNTITLED.BAS *
'* Author : Bill Bubel *
' *
'* Date : 7/31/2009 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
; Initialize your hardware first.
INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
DEFINE OSC 4 'Define the Osc to 4 MHz
asm
bsf OSCCON, SCS1 ; 1x = Internal Block
bcf OSCCON, SCS0 ; 00 = Primary Oscillator (20Mhz?)
bsf OSCCON, IRCF2 ; 111=8000 110=4000 101=2000
bsf OSCCON, IRCF1 ; 100=1000 011=0500 010=0250
bcf OSCCON, IRCF0 ; 001=0125 000=0032
MSTABLE010 btfss OSCCON, IOFS
bra MSTABLE010 ; wait until Oscillator is stable
endasm
LED1 VAR PORTB.2
DutyCycle VAR BYTE
TotalCount CON 50000
ONcount VAR WORD
OFFcount VAR WORD
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = $00 ; Prescaler = 1:1, TMR OFF
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
Main:
FOR DutyCycle = 0 TO 255 ; Ramp up
GOSUB SetDutyCycle
PAUSE 5
NEXT DutyCycle
FOR DutyCycle = 254 TO 1 STEP -1 ; Ramp down
GOSUB SetDutyCycle
PAUSE 5
NEXT DutyCycle
GOTO Main
SetDutyCycle:
ONcount = TotalCount*/DutyCycle
OFFcount = TotalCount - ONcount
IF DutyCycle = 0 THEN
T1CON.0 = 0 ; turn off timer
LOW LED1 ; idle LOW
ELSE
T1CON.0 = 1 ; timer on if DutyCycle > 0
ENDIF
RETURN
DISABLE DEBUG
'---[TMR1 - interrupt handler]------------------------------------------------
@Timer1 = TMR1L ; map timer registers to a word variable
Timer1 VAR WORD EXT
ToggleLED1:
IF LED1 THEN
LOW LED1
T1CON.0 = 0 ; stop the timer
Timer1 = OFFcount ; Load OFF count
T1CON.0 = 1 ; start timer
ELSE
HIGH LED1
T1CON.0 = 0 ; stop the timer
Timer1 = ONcount ; Load ON count
T1CON.0 = 1 ; start timer
ENDIF
@ INT_RETURN
ENABLE DEBUG
Bookmarks