Hi!
I manage to compile and modify the example from that link www.picbasic.co.uk/forum/cont...-DT-interrupts, for pic 16877. Because the pic I want to use for three phase spwm signal is (16f777) which has 3 CCP module and I' m waiting for it to come the problem it is not includeded in ISIS simulator that is why I used pic 168777 having 2 CCP module for simulation and is present in ISIS and my college lab. I belive if I manage to generate two phase spwm it became eaasy for 3 phase spmw.
here is the code and attachement of my output from ISIS and mysinelooktable and
define OSC 4
STEPCOUNT var byte
STEPCOUNT1 var byte
STEPCOUNT = 0 'pointer for phase one in sinearray
STEPCOUNT1 = 0 'pointer for phase two in sine array
ADCON0 = %00000000
ADCON1 = %00000000
TRISB = %11111111
TRISC = %11111001 'PMW output for CCP1 AND CCP2
TRISA = %11111111
TMR2 = 117
PR2 = 55 'set for 18Khz HPWM
CCP1CON = %00001100 'set CCP1 for PWM OPERATION
CCP2CON = %00001100 'set CCP2 for PWM OPERATION
T2CON = %00000100 'TIMER2ON and prescale of 1:1
sineval var byte[36]
sineval[0] = 128
sineval[1] = 150
sineval[2] = 171
sineval[3] = 191
sineval[4] = 209
sineval[5] = 225
sineval[6] = 238
sineval[7] = 247
sineval[8] = 253
sineval[9] = 255
sineval[10] = 253
sineval[11] = 247
sineval[12] = 238
sineval[13] = 225
sineval[14] = 209
sineval[15] = 191
sineval[16] = 171
sineval[17] = 150
sineval[18] = 128
sineval[19] = 105
sineval[20] = 84
sineval[21] = 64
sineval[22] = 46
sineval[23] = 30
sineval[24] = 17
sineval[25] = 8
sineval[26] = 2
sineval[27] = 0
sineval[28] = 2
sineval[29] = 8
sineval[30] = 17
sineval[31] = 30
sineval[32] = 46
sineval[33] = 64
sineval[34] = 84
sineval[35] = 105
timerone var word
Temp var byte
Temp1 var byte
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System emp
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _sine, ASM, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = 000001 ; Prescaler = 1;1, TMR1 ON
TMR1L = 255
TMR1H = 254
@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
timerone = 64980 ;gives about 50 htz sine
Main:
PAUSE 5
GOTO Main
'---[TMR1_INT - interrupt handler]------------------------------------------
sine:
TMR1L = timerone.byte0
TMR1H = timerone.byte1
TeMP = sineval[STEPCOUNT]
CCP1CON.4 = Temp.0 ' bit 0
CCP1CON.5 = Temp.1 ' bit 1
CCPR1L = Temp >>2 'Bit 2-7
TeMP1 = sineval[STEPCOUNT1]
CCP2CON.4 = Temp.0 ' bit 0
CCP2CON.5 = Temp.1 ' bit 1
CCPR2L = Temp >>2 'Bit 2-7
if stepcount = 36 then stepcount =0
if stepcount1 = 24 then stepcount1 =0
stepcount = stepcount +1
stepcount = stepcount1 +1
@ INT_RETURN
any one can help me
Bookmarks