
	LIST P=16F871
	#INCLUDE "P16F871.INC"   
	ERRORLEVEL      -302    ;SUPRIME LA ADVERTENCIA SOBRE LOS BANCOS DE MEMORIA
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC

;*************************************************************
;DECLARACION DE VARIABLES
;*************************************************************

AUX_LOW		EQU H'20'
AUX_HIGH	EQU H'21'
THIGH		EQU H'22'
TLOW		EQU H'23'
PDel0		EQU	H'24'
FLAGS		EQU	H'25'

#define BANCO0 bcf STATUS,5
#define BANCO1 bsf STATUS,5
#define FLAG FLAGS,0
#define SINCRONIZAR? FLAGS,1
#define CRUCE_CERO PORTB,0
#define PWM_1_AUX PORTC,0
#define PWM_2_AUX PORTC,1
#define PWM_1 PORTC,2
#define PWM_2 PORTC,3
#define SINCRONIZA PORTC,4

	ORG		0x00
	GOTO	INICIO

;*************************************************************
;PROGRAMA PRINCIPAL
;*************************************************************

INICIO
	BANCO1
	movlw	b'11100000'	
	movwf	TRISC		;PONGO PIN 0, 1, 2, 3, 4 DEL PUERTO C COMO SALIDA.

;*************************************************************
;CONFIGURACION DEL TIMER 0
;*************************************************************

	movlw	b'00000001'	;Se selecciona TMR0 modo temporizador y preescaler de 1/16.
	movwf	OPTION_REG

;*************************************************************
;CONDICIONES INICIALES
;*************************************************************

	BANCO0
	clrf	PORTC
	clrf	FLAGS

;*************************************************************
;SEMICICLO POSITIVO
;*************************************************************

POSITIVO_0					;Medio ciclo del cruce por cero

	movlw	.174			;valor del offset del TMR0; Temporización = Ciclo de instrucción*(256-TMR0)*Divisor de Frecuencia
POSITIVO_0_1
	bcf 	INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf 	PWM_1_AUX		;pin para positivo del Puente H
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.89
	goto	$+1
	goto	$+1
	nop
	goto	$+2

POSITIVO_1					;este sera el primer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_2					;este sera el segundo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1	
	goto	$+2

POSITIVO_3					;este sera el tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf 	INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_4					;este sera el cuarto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1	
	goto	$+1	
	bsf		PWM_1			;lo activamos
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_5					;este sera el quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf 	INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1	
	bsf		PWM_1			;lo activamos
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_6					;este sera el sexto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_7					;este sera el septimo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_8					;este sera el octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf 	INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop
	goto	$+2

POSITIVO_9					;este sera el noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_10					;este sera el decimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo
	
	goto	$+1
	btfss	FLAG
	goto	$+5
	movlw	.87
	goto	$+1
	nop
	goto	$+2

POSITIVO_11					;este sera el decimo primer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_4		;llamamos demora

	bcf		FLAG			;limpiamos la bandera cuando no deberia haber cruce por cero

	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_12					;este sera el decimo segundo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_13					;este sera el decimo tercer PWM con dutty

 		
	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_14					;este sera el decimo cuarto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_15					;este sera el decimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos 
	call	DEMORA_14		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_16					;este sera el decimo sexto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_17					;este sera el decimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_18					;este sera el decimo octavo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf 	INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_19					;este sera el decimo noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_20					;este sera el vigesimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_21					;este sera el vigesimo primero PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_22					;este sera el vigesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_23					;este sera el vigesimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_24					;este sera el vigesimo cuarto PWM con dutty

	movlw	.86				;valor del offset del TMR0
 	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_25					;este sera el vigesimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_26					;este sera el vigesimo sexto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_27					;este sera el vigesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_28					;este sera el vigesimo octavo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_28		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_29					;este sera el vigesimo noveno PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_30					;este sera el trigesimo PWM con dutty

	movlw	.85				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_31					;este sera el trigesimo primer PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_32					;este sera el trigesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_28		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_33					;este sera el trigesimo tercero PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_34					;este sera el trigesimo cuarto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_35					;este sera el trigesimo quinto PWM con dutty

	goto	$+1
	bcf		INTCON,T0IF
	movlw	.86				;valor del offset del TMR0
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_36					;este sera el trigesimo sexto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_37					;este sera el trigesimo septimo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_38					;este sera el trigesimo octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_39					;este sera el trigesimo noveno PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_21		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_40					;este sera el cuadragesimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_41					;este sera el cuadragesimo primer PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_42					;este sera el cuadragesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_43					;este sera el cuadragesimo tercer PWM con dutty

	goto	$+1
	bcf		INTCON,T0IF
	movlw	.86				;valor del offset del TMR0
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_44					;este sera el cuadragesimo cuarto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_45					;este sera el cuadragesimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_46					;este sera el cuadragesimo sexto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_14		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_47					;este sera el cuadragesimo septimo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_48					;este sera el cuadragesimo octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

POSITIVO_49					;este sera el cuadragesimo noveno PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0			;y mandamos programa a punto de sincronismo

POSITIVO_50					;este sera el quincuagesimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0			;y mandamos programa a punto de sincronismo
	goto	$+1

POSITIVO_51					;este sera el quincuagesimo primer PWM con dutty

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0			;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_52					;este sera el quincuagesimo segundo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora	
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop
	goto	$+2

POSITIVO_53					;este sera el quincuagesimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1

	btfss	SINCRONIZAR?	;testeamos bandera para sincronizar
	bcf		SINCRONIZA		;sacamos de sincronizacion luego de cada onda senoidaL

	bsf		PWM_1			;lo activamos
	call	DEMORA_7		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_54					;este sera el quincuagesimo cuarto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_6		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_55					;este sera el quincuagesimo quinto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_5		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

POSITIVO_56					;este sera el quincuagesimo sexto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_4		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_57					;este sera el quincuagesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_1			;lo activamos
	call	DEMORA_3		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_58					;este sera el quincuagesimo octavo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_1			;lo activamos
	call	DEMORA_2		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_59					;este sera el quincuagesimo nooveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_1			;lo activamos
	call	DEMORA_1		;llamamos demora
	bcf		PWM_1			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.176
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

POSITIVO_60					;Medio ciclo del cruce por cero

	movlw	.174			;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bcf		PWM_1_AUX		;pin para positivo del Puente H
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	goto	$+1
	btfss	FLAG
	goto	$+6
	movlw	.176
	goto	$+1
	goto	$+1
	nop
	goto	$+2

;*************************************************************
;SEMICICLO NEGATIVO
;*************************************************************

NEGATIVO_0					;Medio ciclo del cruce por cero

	movlw	.174			;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2_AUX		;pin para positivo del Puente H
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.88
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_1					;este sera el primer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1	
	bsf		PWM_2			;lo activamos
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_2					;este sera el segundo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.88
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_3					;este sera el tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_4					;este sera el cuarto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.88
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_5					;este sera el quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_6					;este sera el sexto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_7					;este sera el septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_8					;este sera el octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop
	goto	$+2

NEGATIVO_9					;este sera el noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1	
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_10					;este sera el decimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.89
	goto	$+1
	nop
	goto	$+2

NEGATIVO_11					;este sera el decimo primer PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.89
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_12					;este sera el decimo segundo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.89
	goto	$+1
	nop
	goto	$+2

NEGATIVO_13					;este sera el decimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.88
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_14					;este sera el decimo cuarto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.89
	goto	$+1
	nop
	goto	$+2

NEGATIVO_15					;este sera el decimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_16					;este sera el decimo sexto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_17					;este sera el decimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.89
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_18					;este sera el decimo octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_19					;este sera el decimo noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.89
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_20					;este sera el vigesimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_21					;este sera el vigesimo primero PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.88
	goto	$+2

NEGATIVO_22					;este sera el vigesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_23					;este sera el vigesimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_24					;este sera el vigesimo cuarto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.88
	goto	$+1
	goto	$+2

NEGATIVO_25					;este sera el vigesimo quinto PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_26					;este sera el vigesimo sexto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.88
	goto	$+1
	goto	$+2

NEGATIVO_27					;este sera el vigesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_28					;este sera el vigesimo octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_28		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	goto	$+1	
	goto	NEGATIVO_29_1

NEGATIVO_29					;este sera el vigesimo noveno PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	NEGATIVO_30
	goto	NEGATIVO_30

NEGATIVO_29_1				;este sera el vigesimo noveno PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	nop

NEGATIVO_30					;este sera el trigesimo PWM con dutty

	movlw	.86				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	NEGATIVO_31
	nop

NEGATIVO_31_1					;este sera el trigesimo primer PWM con dutty

	bsf		PWM_2
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos

	btfss	FLAG
	goto	NEGATIVO_32
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	NEGATIVO_32

NEGATIVO_31					;este sera el trigesimo primer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_28		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+2
	goto	$+1

NEGATIVO_32					;este sera el trigesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_28		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	goto	$+1
	goto	$+2

NEGATIVO_33					;este sera el trigesimo tercero PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_34					;este sera el trigesimo cuarto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.88
	goto	$+1
	goto	$+2

NEGATIVO_35					;este sera el trigesimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_36					;este sera el trigesimo sexto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.88
	goto	$+1
	goto	$+2

NEGATIVO_37					;este sera el trigesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_38					;este sera el trigesimo octavo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.88
	goto	$+1
	goto	$+2

NEGATIVO_39					;este sera el trigesimo noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_21		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_40					;este sera el cuadragesimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_41					;este sera el cuadragesimo primer PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+3
	movlw	.89
	goto	$+2

NEGATIVO_42					;este sera el cuadragesimo segundo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_43					;este sera el cuadragesimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_44					;este sera el cuadragesimo cuarto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_45					;este sera el cuadragesimo quinto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_46					;este sera el cuadragesimo sexto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_14		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_47					;este sera el cuadragesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.89
	goto	$+1
	goto	$+1
	nop
	goto	$+2

NEGATIVO_48					;este sera el cuadragesimo octavo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop
	goto	$+2

NEGATIVO_49					;este sera el cuadragesimo noveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_50					;este sera el quincuagesimo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop	
	goto	$+2

NEGATIVO_51					;este sera el quincuagesimo primer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_52					;este sera el quincuagesimo segundo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+5
	movlw	.88
	goto	$+1
	nop	
	goto	$+2

NEGATIVO_53					;este sera el quincuagesimo tercer PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_7		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_54					;este sera el quincuagesimo cuarto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_6		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_55					;este sera el quincuagesimo quinto PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_5		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+4
	movlw	.89
	nop
	goto	$+2

NEGATIVO_56					;este sera el quincuagesimo sexto PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_4		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_57					;este sera el quincuagesimo septimo PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bsf		PWM_2			;lo activamos
	call	DEMORA_3		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.90
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_58					;este sera el quincuagesimo octavo PWM con dutty

	movlw	.88				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	bsf		PWM_2			;lo activamos
	call	DEMORA_2		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+7
	movlw	.89
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_59					;este sera el quincuagesimo nooveno PWM con dutty

	movlw	.87				;valor del offset del TMR0
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	goto	$+1
	bsf		PWM_2			;lo activamos
	call	DEMORA_1		;llamamos demora
	bcf		PWM_2			;acabo tiempo dutty, apagamos
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	btfss	FLAG
	goto	$+6
	movlw	.176
	goto	$+1
	goto	$+1
	goto	$+1
	goto	$+2

NEGATIVO_60					;Medio ciclo del cruce por cero

	movlw	.175			;valor del offset del TMR0para 65,60uS
	bcf		INTCON,T0IF
	movwf	TMR0			;aqui empieza a contar
	nop
	bcf		PWM_2_AUX		;pin para positivo del Puente H
	call	CHEQUEO
	btfsc	SINCRONIZAR?	;testeamos bandera para sincronizar
	goto	CRUCE_0_1		;y mandamos programa a punto de sincronismo

	goto	$+1
	nop
	btfss	FLAG
	goto	$+4
	movlw	.175
	goto	$+1
	goto	POSITIVO_0_1
	goto	POSITIVO_0 		;Empezamos nuevamente la onda

;*************************************************************
;BANDERA PARA EL CRUCE POR CERO
;*************************************************************

CHEQUEO
	btfsc	CRUCE_CERO		;chequeamos si cruzo por cero la  senoidal de la red
	goto	$+4				;ya cruzo por cero
	btfss	INTCON,T0IF		;chequeamos si desbordo
	goto	$-3				;todavia no pasaron los 138,8uS, esperamos
	goto	$+6				;para que continue ejecutando siguiente PWM ya que TMR0 desbordo
	btfsc	FLAG			;miramos si FLAG esta a 0
	goto	$-4				;esta a 1, no hacemos caso
	bsf		FLAG			;esta a 0, lo ponemos a 1 
	bsf		SINCRONIZAR?	;bandera para saber que tiene que sincronizar
	return
	bcf		SINCRONIZAR?	;limpiamos bandera para saber que tiene que sincronizar
	return

;*************************************************************
;CRUCE POR CERO
;*************************************************************

CRUCE_0
	nop
	call	DEMORA_SINC
	bsf		SINCRONIZA 		;bit de salida para SINCRONIZACION
	goto	POSITIVO_51

CRUCE_0_1
	clrf	PORTC
	btfsc	CRUCE_CERO 		;Chequeamos si ya no esta en 1 el pin de cruce por cero
	goto	$-1
	btfss	CRUCE_CERO 		;Chequeamos si ya esta en 1 y ahora si mandamos a sincronizar.
	goto	$-1
	bsf		PWM_1_AUX		;pin para positivo del Puente H
	call	DEMORA_SINC
	bsf		SINCRONIZA 		;bit de salida para SINCRONIZACION
	goto	POSITIVO_51

;*************************************************************
;DEMORAS
;*************************************************************

DEMORA_SINC
	movlw	.93
	goto	A

DEMORA_28					;esta tendra 129,6uS
	movlw	.159
	goto	$+2

DEMORA_21					;esta tendra 97,2uS
	movlw	.119
	nop
	goto	A

DEMORA_14					;esta tendra 64,8uS
	movlw	.78
	goto	$+2

DEMORA_7					;esta tendra 32,4uS
	movlw	.38
	nop
	goto	A

DEMORA_6					;esta tendra 27,6uS
	movlw	.32
	nop
	goto	A

DEMORA_5					;esta tendra 23uS
	movlw	.26
	goto	$+4

DEMORA_4					;esta tendra 18,4uS
	movlw	.20
	goto	$+4

DEMORA_3					;esta tendra 13,8uS
	movlw	.15
	goto	A

DEMORA_2					;esta tendra 9,2uS
	movlw	.9
	nop
	goto	A

DEMORA_1					;esta tendra 4,6uS
	movlw	.4				; 1 set numero de repeticion 
A	movwf	PDel0			; 1 |
PLoop0
	clrwdt					; 1 clear watchdog
	decfsz	PDel0,1			; 1 + (1) es el tiempo 0  ?
	goto	PLoop0			; 2 no, loop
	goto	$+1				; 2 ciclos delay
	return					; 2+2 Fin.

	END						;fin de programa