I'm convert code from MicroC to Bascom Avr except marked line with [b:779268eb16]'THIS LINE!!!!!!!!!. [/b:779268eb16]
Need assistance and help for convert this marked lines [code:1:779268eb16]
'*******************************************************************************
'* Programmer: Syed Tahmid Mahbub in MicroC
'* Program Convert to Bascom Avr: Ivica Lacmanovic
'* Target Microcontroller: ATMEGA16
'* Compiler: Bascom AVR 2.0.7.3
'*******************************************************************************
$regfile = "m16def.dat" ' specify the used micro
$crystal = 16000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 128 ' default use 128 for the hardware stac
$swstack = 64 ' default use 64 for the SW stack
$framesize = 64
' variable
'------------------------------
Dim Sin_table(32) As Integer ' Half period Sine wave table 32 segments
Dim Index As Byte
' Config Ports
'------------------------------
Config Portd = Output
Mosa Alias Pind.0 ' #define MOSA PORTD0_bit
Mosb Alias Pind.1 ' #define MOSB PORTD1_bit
Mosc Alias Pind.2 ' #define MOSC PORTD2_bit
Mosd Alias Pind.3 ' #define MOSD PORTD3_bit
For Index = 0 To 31
Sin_table(index + 1) = Lookup(index , Sine_dat) ' Read sine_dat "1 to 32"
Next Index
Dim Flagreg As Byte ' unsigned char FlagReg;
'********************************************************************************
#define Direction Flagreg.b0 ' THIS LINE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'********************************************************************************
' 0 -> MOS A + D
' 1 -> MOS B + C
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 Byte
Enable Ovf0
On Ovf0 Timer1_ovf
Do
Set_freq = 410
Tbl_pointer_shift = 0
Tbl_pointer_new = 0
Tbl_pointer_old = 0
Duty_cycle = 0
Ddrc = &B11111111 ' DDRC = 0xFF;
Ddrd = &B11111111 ' DDRD = 0xFF;
Ocr1ah = 0
Ocr1al = 0
Tccr1a = &B10000010 ' TCCR1A = 0x82;
Icr1h = &B00000011 ' ICR1H = 0x03;
Icr1l = &B11100111 ' ICR1l = 0xe7;
' ICR1 = 999 -> TOP -> 16kHz
Timsk = &B00000100 ' Timsk = 0x04;
Tccr1b = &B00011001 ' Tccr1b = 0x19;
'*******************************************************************************
Sreg_i_bit = 1 ' THIS LINE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' If possibble replace thih line with Enable Interrupts
'*******************************************************************************
Loop
End ' End Program
'***********************************************Interrupt0**********************
Void Interrupt() Org Ivt_addr_timer1_ovf{ ' THIS LINE !!!!!!!!!!!!!!!!!!!!!!!!!
' IF POSSIBLE TO REPLACE WITH Timer1_ovf:
'*******************************************************************************
Tbl_pointer_new = Tbl_pointer_new + Set_freq
If Tbl_pointer_new < Tbl_pointer_old Then
If Direction = 0 Then
Mosa = 0
Mosd = 0
Mosb = 1
Mosc = 1
Direction = 1
Else
Mosb = 0
Mosc = 0
Mosa = 1
Mosd = 1
Direction = 0
End If
End If
Tbl_pointer_shift = Tbl_pointer_new : Shift Tbl_pointer_shift , Right , 11 'TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 11;
Duty_cycle = Tbl_pointer_shift
Tbl_pointer_shift = Sin_table(duty_cycle)
Ocr1ah = Tbl_pointer_shift : Shift Ocr1ah , Right , 8 'OCR1AH = TBL_POINTER_SHIFT >> 8;
Ocr1al = Tbl_pointer_shift And &B00001111 'OCR1AL = TBL_POINTER_SHIFT & 0x0F;
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 , 989 , 979 , 958 , 928 , 889 , 840 , 783 , 718 , 645 , 566 , 480 , 390 , 296 , 199 , 100 , 0 [/code:1:779268eb16]
[b:779268eb16][color=red:779268eb16](BASCOM-AVR version : 2.0.7.6 )[/b:779268eb16][/color:779268eb16]
↧