Yes,I have DT_INTS_14.bas file,I write correct name.
I do what you tell me,but now I have errors.
If I understudy you,i MUST WRITE THAT,CODE?
' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
;wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
' --------------------------------------------------------------------------
I do that but I have errors when I compile.
This program in my PicBasic :
Code:
'****************************************************************
'* Name : Test_SPWM.pbp *
'* Author : Darrel Taylor *
'* Date : 9/30/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
; Initialize your hardware first
DEFINE OSC 20
CLEAR
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
INCLUDE "SPWM_INT.bas" ; Software PWM module
DEFINE SPWM_FREQ 40 ; SPWM Frequency
DEFINE SPWM_RES 256 ; SPWM Resolution
DutyVars VAR BYTE[3] ; DutyCycle Variables
DutyVar1 VAR DutyVars[0] ; group them in an array for easy access
DutyVar2 VAR DutyVars[1] ; with FOR loops etc.
DutyVar3 VAR DutyVars[2]
ASM
SPWM_LIST macro ; Define PIN's to use for SPWM
SPWM_PIN PORTB, 0, _DutyVar1
SPWM_PIN PORTB, 1, _DutyVar2
SPWM_PIN PORTB, 2, _DutyVar3
endm
SPWM_INIT SPWM_LIST ; Initialize the Pins
ENDASM
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, SPWMhandler, ASM, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
;_____________________________________________________________________________
RandVar VAR WORD : RandVar = 12345
LoopCount VAR WORD
Main:
wsave VAR BYTE $70 SYSTEM ' location for W if in bank0
;wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' if using $70, comment wsave1-3
; Simple Demo to fade/flash some LED's
DutyVar1 = 5 ; Start with 3 LED's at different
DutyVar2 = 50 ; brightness
DutyVar3 = 150
pause 3000
FOR LoopCount = 1 to 4 ; Reapeat 4 times
for DutyVar1 = 0 to 150 ; Fade LED1 UP
pause 10
RANDOM RandVar
DutyVar3 = RandVar & $3F ; Give LED3 a random dutycycle
next DutyVar1
for DutyVar1 = 150 to 0 STEP -1 ; Fade LED1 Down
pause 10
RANDOM RandVar
DutyVar2 = RandVar & $3F ; Give LED2 a random dutycycle
next DutyVar1
NEXT LoopCount
GOTO Main
is correct?
Bookmarks