Está en la página 1de 4

; Note: MCU frequency = 4MHz - crystal oscillators used

Start ORG 0x00 ;code begins


BSF 03,5 ; migrate to bank1 to setup ports
MOVLW 00h
MOVWF 05h
MOVWF 06h
BCF 03,5 ; go back to bank0

; This routine loads SVM data into an allocated registers (SVM registers)
movlw 00h
movwf 10h ;file 10h is the table pointer
movlw 13h
movwf 04h ; SVM registers starts from 13h to 1ah
getnext incf 10h,1 ;increment table pointer
movf 10h,0 ;move the content of 10h to the working reg

continue movf 10h,0


call tableSVM
movwf 00h ;store the SVM vectors returned from the table in files
incf 04h
xorlw 0aah ;check when last line of data table is returned
btfsc 03,2 ;if last line is returned, generate SVM signals
goto gen_svm
goto getnext

;routine that returns SVM data to be saved in registers


tableSVM ADDWF 02h,1 ;Add W to Program Counter

RETLW 00h ; this line is skipped!

retlw 1ch ;SW vector0 =13h


retlw 8ch ;SW vector1 =14h
retlw 0c4h ;SW vector2 =15h
retlw 54h ;SW vector3 =16h
retlw 70h ;SW vector4 =17h
retlw 38h ;SW vector5 =18h
retlw 0a8h ;SW vector6 =19h
retlw 0e0h ;SW vector7 =1ah
retlw 0aah ;when this line is returned, return ends!

; subroutine for switching times(T0,T1, and T2) - use Delay Code Generator
DelT0_2 movlw 0ah ;Delay for 33us
movwf 0fh
del0_2 DECFSZ 0fh,1
GOTO del0_2
RETURN

DelT0 movlw 15h ;Delay for 66us


movwf 0fh
del0 DECFSZ 0fh,1
GOTO del0
RETURN

DelT1 movlw 0bh ;Delay for 36us


movwf 0fh
del1 DECFSZ 0fh,1
GOTO del1
RETURN
DelT2 movlw 20h ;Delay for 98us
movwf 0fh
del2 DECFSZ 0fh,1
GOTO del2
RETURN

;this subroutine generates SVM (Symmetric algorithm) switching signals


gen_svm
movf 13h,0 ;sector1 switching signals
movwf 06h
CALL DelT0_2

movf 14h,0
movwf 06h
CALL DelT1
movf 15h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 15h,0
movwf 06h
CALL DelT2
movf 14h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2

movf 13h,0 ;sector2 switching signals


movwf 06h
CALL DelT0_2

movf 16h,0
movwf 06h
CALL DelT1
movf 15h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 15h,0
movwf 06h
CALL DelT2
movf 16h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2

movf 13h,0 ;sector3 switching signals


movwf 06h
CALL DelT0_2

movf 16h,0
movwf 06h
CALL DelT1
movf 17h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 17h,0
movwf 06h
CALL DelT2
movf 16h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2

movf 13h,0 ;sector4 switching signals


movwf 06h
CALL DelT0_2

movf 18h,0
movwf 06h
CALL DelT1
movf 17h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 17h,0
movwf 06h
CALL DelT2
movf 18h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2 ;

movf 13h,0 ;sector5 switching signals


movwf 06h
CALL DelT0_2

movf 18h,0
movwf 06h
CALL DelT1
movf 19h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 19h,0
movwf 06h
CALL DelT2
movf 18h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2

movf 13h,0 ;sector6 switching signals


movwf 06h
CALL DelT0_2

movf 14h,0
movwf 06h
CALL DelT1
movf 19h,0
movwf 06h
CALL DelT2

movf 1ah,0
movwf 06h
CALL DelT0

movf 19h,0
movwf 06h
CALL DelT2
movf 14h,0
movwf 06h
CALL DelT1

movf 13h,0
movwf 06h
CALL DelT0_2

GOTO gen_svm

end

También podría gustarte