'
' ***************************************
' * DDS Fullswing SinWave generator
' * 2022.05.14
' ***************************************
$regfile = "m88pdef.DAT"
$crystal = 20000000 ' Clock:Ext 19.66MHz
$hwstack = 32 ' default
$swstack = 10 ' default
Config Portd = Output
Config Portb.0 = Output
Dim Fdt As Byte ' Waveform data
Dim Wpt As Byte ' EEPROM write Pointer
Dim Rpt As Byte ' EEPROM read Pointer
Dim Eck As Byte
' ***************************
' * Eeprom Data check
' ***************************
Restore Wfdat
For Wpt = 0 To 159
Read Fdt ' Read orijinal data
Readeeprom Eck , Wpt ' Read EEPROM data
If Fdt <> Eck Then Goto Epset ' If don't match, goto EEPROM write
Next Wpt
Goto T0set ' goto Timer0 config
' ***************************
' * Eeprom write routine
' ***************************
Epset:
Restore Wfdat
For Wpt = 0 To 159 ' Data transfer to Eeprom
Read Fdt
Writeeeprom Fdt , Wpt
Next Wpt
Portb.0 = 1 ' EEPROM write indicater
' ***************************
' * Timer setting
' ***************************
T0set:
Config Timer0 = Timer , Prescale = 1 , Clear Timer = 1 , Compare A = Disconnect
Ocr0a = 81 ' Division number setting
On Oc0a Outsub Nosave ' Jump destination at the interrupt
Enable Oc0a ' Comparator 0a interrupt enable
Enable Interrupts ' All interrupt enable
' ***************************
' * Main routine
' ***************************
Main:
Do
nop
Loop
' ***********************
' * Cosin Waveform Data
' * 2.25deg.x 160points
' ***********************
Wfdat:
Data 254 , 254 , 254 , 253 , 252 , 252 , 250 , 249 , 248 , 246 '0-9
Data 244 , 242 , 240 , 238 , 235 , 233 , 230 , 227 , 224 , 220 '10-19
Data 217 , 213 , 209 , 206 , 202 , 198 , 193 , 189 , 185 , 180 '20-29
Data 176 , 171 , 166 , 161 , 157 , 152 , 147 , 142 , 137 , 132 '30-39
Data 127 , 122 , 117 , 112 , 107 , 102 , 97 , 93 , 88 , 83 '40-49
Data 78 , 74 , 69 , 65 , 61 , 56 , 52 , 48 , 45 , 41 '50-59
Data 37 , 34 , 30 , 27 , 24 , 21 , 19 , 16 , 14 , 12 '60-69
Data 10 , 8 , 6 , 5 , 4 , 2 , 2 , 1 , 0 , 0 '70-79
Data 0 , 0 , 0 , 1 , 2 , 2 , 4 , 5 , 6 , 8 '80-89
Data 10 , 12 , 14 , 16 , 19 , 21 , 24 , 27 , 30 , 34 '90-99
Data 37 , 41 , 45 , 48 , 52 , 56 , 61 , 65 , 69 , 74 '100-109
Data 78 , 83 , 88 , 93 , 97 , 102 , 107 , 112 , 117 , 122 '110-119
Data 127 , 132 , 137 , 142 , 147 , 152 , 157 , 161 , 166 , 171 '120-129
Data 176 , 180 , 185 , 189 , 193 , 198 , 202 , 206 , 209 , 213 '130-139
Data 217 , 220 , 224 , 227 , 230 , 233 , 235 , 238 , 240 , 242 '140-149
Data 244 , 246 , 248 , 249 , 250 , 252 , 252 , 253 , 254 , 254 '150-159
' **********************************
' * Waveform output subroutine
' **********************************
'
Outsub:
Readeeprom Fdt , Rpt
Portd = Fdt
Incr Rpt
If Rpt = 160 Then Rpt = 0
Return
|