This has assembly level in Main Program some C based code in defining region.
How to find suitable compiler?
Code: Select all
; **** Encabezado(header) ****
list p=16f628A ; list directive to define processor
#include <p16f628A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _LVP_OFF & _MCLRE_ON
;**** Definicion de variables(Definition of variables)****
Flags equ 0x20 ; Registro para guardar banderas.-
Selec equ 0 ; Bit para indicar seleccion(Selec=1->500Hz; Selec=0->2kHz).-
;**** Definiciones para el ensamblador(Definitions for the assembler) ****
#define Signal Flags,Selec
;/////////////////////////////////
;**** Inicio del Micro(Home of the Micro) ****
Reset.
org 0x00 ; Aquí comienza el micro.-
goto Inicio ; Salto a inicio de mi programa.-
; **** Programa Principal(Main Program)****
org 0x05
Inicio
bsf STATUS,RP0 ; Banco 1
bsf TRISB,0 ; Como Entrada.-
bcf TRISB,3 ; RB3 como Salida.
bcf STATUS,RP0 ; Banco 0.-
movlw b'00000110' ; Se selecciona TMR2, preescaler de 1/16.-
movwf T2CON
bsf STATUS,RP0 ; Banco 1
movlw 0x7C ; Inicia periodo de 500Hz.-
movwf PR2
bcf STATUS,RP0 ; Banco 0.-
bsf Signal
movlw 0x3E ; Ciclo de trabajo 50%
movwf CCPR1L
bsf CCP1CON,CCP1X
bcf CCP1CON,CCP1Y
bsf CCP1CON,CCP1M3 ; Configura modulo CCP modo PWM.-
bsf CCP1CON,CCP1M2
Bucle
btfss PORTB,0 ; Testea si se quiere cambiar de Frecuencia.-
goto $-1 ; No se quiere cambiar.-
btfss Signal ; A cual cambiar?
goto Cambiar500Hz
Cambiar2kHz
bsf STATUS,RP0 ; Banco 1
movlw 0x1E
movwf PR2
bcf STATUS,RP0 ; Banco 0
bcf Signal ; Señal de 2kHz
movlw 0x0F ; Ciclo de trabajo 50%
movwf CCPR1L
goto Bucle ;
Cambiar500Hz
bsf STATUS,RP0 ; Banco 1
movlw 0x7C ; Inicia periodo de 500Hz.-
movwf PR2 ; Señal de 500 Hz.-
bcf STATUS,RP0 ; Banco 0.-
bsf Signal
movlw 0x3E ; Ciclo de trabajo 50%
movwf CCPR1L
goto Bucle
;...............................................
end