Hi all
Is there some problem in using the SPWM code and "debug" together? I use debug with
a VFD display for trouble shooting but have not been able to get it to work when the SPWM technique is used.
Below is a stripped down version of the demo which runs (osc 20) but does not register on the display.
I can use the same hardware setup (16f628a) with different code (no SPWM) and use the display (osc 20) without a problem.
Thanks in advance
'SPWM code
DEFINE OSC 20
CLEAR
CMCON = 7
Define DEBUG_REG PORTA ' Debug PORT
Define DEBUG_BIT 0 ' *** Debug pin Bit-0 ***
Define DEBUG_BAUD 9600 ' *** Debug Baud Rate ***
Define DEBUG_MODE 0 ' Set Serial Mode to Inverted
Define DEBUG_PACING 200 ' Delay 'in Us' between characters sent
Debug $0E 'Clr
Debug $0D 'CR
pause 1000
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
;_________________________________________________ ____________________________
LoopCount VAR WORD
Main: ; Simple Demo to fade/flash some LED's
loop:
FOR LoopCount = 1 TO 4 ; Reapeat 4 times
FOR DutyVar1 = 5 TO 255 step 1
pause 10
next
Debug $0D 'CR ;display
Debug, dec2 loopcount
FOR DutyVar1 = 255 TO 5 step -1
pause 10
next
next loopcount
GOTO loop
Bookmarks