hi,
there was a few errors in the code
pin is input port is output here is what you can look for in the code
[i:816bf83295]Enable Ovf1
On Ovf1 Timer1_ovf
Timer1_ovf:[/i:816bf83295]
and the main [i:816bf83295]do loop [/i:816bf83295]
[code:1:816bf83295]$regfile = "m16def.dat"
$crystal = 16000000
$hwstack = 128
$swstack = 64
$framesize = 64
Config Portd = Output
Mosa Alias Portd.0
Mosb Alias Portd.1
Mosc Alias Portd.2
Mosd Alias Portd.3
Dim Sin_table(32) As Byte ' Sine_table
Dim Index As Byte
Dim Direction As Bit
Dim Tbl_pointer_new As Integer , Tbl_pointer_old As Integer
Dim Tbl_pointer_shift As Integer , Set_freq As Integer
Dim Tbl_temp As Integer
Dim Duty_cycle As Word
For Index = 0 To 31
Sin_table(index + 1) = Lookup(index , Sine_dat) ' Read sine_dat
Next Index
Set_freq = 410
Tbl_pointer_shift = 0
Tbl_pointer_new = 0
Tbl_pointer_old = 0
Duty_cycle = 0
Ddrc = &B11111111
Ddrd = &B11111111
Ocr1ah = 0
Ocr1al = 0
Tccr1a = &B10000010
Icr1h = &B00000011
Icr1l = &B11100111
Timsk = &B00000100
Tccr1b = &B00011001
Enable Ovf1
On Ovf1 Timer1_ovf
Enable Interrupts
Do
!nop
Loop
End
'TIMER1 Overflow
Timer1_ovf:
Tbl_pointer_new = Tbl_pointer_new + Set_freq
If Tbl_pointer_new < Tbl_pointer_old Then
If Direction = 0 Then
Reset Mosa
Reset Mosd
Set Mosb
Set Mosc
Set Direction
Else
Reset Mosb
Reset Mosc
Set Mosa
Set Mosd
Reset Direction
End If
End If
Tbl_pointer_shift = Tbl_pointer_new
Shift Tbl_pointer_shift , Right , 11
Duty_cycle = Tbl_pointer_shift
Tbl_pointer_shift = Sin_table(duty_cycle)
Ocr1ah = High(tbl_pointer_shift)
Ocr1al = Low(tbl_pointer_shift)
Tbl_pointer_old = Tbl_pointer_new
Return
'************ Sine Table data for 32 samples ****************************
Sine_dat:
Data 0 , 100 , 199 , 296 , 390 , 480 , 566 , 645 , 718 , 783 , 840 , 889 , 928 , 958 , 979 , 989
Data 989 , 979 , 958 , 928 , 889 , 840 , 783 , 718 , 645 , 566 , 480 , 390 , 296 , 199 , 100 , 0[/code:1:816bf83295]
↧