⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2ceeprom.asm

📁 pic系列单片机得控制程序 主要进行温度采集和转换控制
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	movlw D'255'
	bsf STATUS, RP0
	movwf TRISB
	bcf STATUS, RP0
	bsf PORTA, 1
_lcd_busy_1
	bcf STATUS, RP0
	bcf     PORTA,2         ; Disable
	nop
	bsf     PORTA,2         ; Enable
	nop
	btfsc   PORTB,7         ; Chequea bit de Busy
	goto    _lcd_busy_1		;
	bcf PORTA, 2
	nop
	bcf PORTA, 1
	bsf STATUS, RP0
	clrf TRISB
	return
_LCD_Busy__end
_LCD_Dato__code
	bcf STATUS, RP0
	bcf PORTA, 1
	bcf PORTA, 0
	movf param00_LCD_Dato, W
	movwf PORTB
	call _LCD_Busy
	bcf PCLATH, 3
	bcf PCLATH, 4
	bcf STATUS, RP0
	bsf PORTA, 0
	bsf PORTA, 2
	nop
	bcf PORTA, 2
	movlw D'45'
	movwf param00_delay_us
	call _delay_us
	bcf PCLATH, 3
	bcf PCLATH, 4
	return
_LCD_Dato__end
_delay_us__code
	rrf param00_delay_us, 1
	rrf param00_delay_us, 1
	movlw D'63'
	andwf param00_delay_us, 1
	movlw D'3'
	subwf param00_delay_us, 1
label_0000
	nop
	decfsz param00_delay_us, 1
	goto label_0000
	nop
	return
_delay_us__end
_LCD_Comando__code
	bcf STATUS, RP0
	bcf PORTA, 1
	bcf PORTA, 0
	movf param00_LCD_Comando, W
	movwf PORTB
	call _LCD_Busy
	bcf PCLATH, 3
	bcf PCLATH, 4
	bcf STATUS, RP0
	bsf PORTA, 2
	nop
	bcf PORTA, 2
	movlw D'45'
	movwf param00_delay_us
	call _delay_us
	bcf PCLATH, 3
	bcf PCLATH, 4
	return
_LCD_Comando__end
_LCD_Ini__code
	movlw D'60'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'5'
	bcf STATUS, RP0
	movwf param00_delay_ms
	call _delay_ms
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'60'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'5'
	bcf STATUS, RP0
	movwf param00_delay_ms
	call _delay_ms
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'60'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'5'
	bcf STATUS, RP0
	movwf param00_delay_ms
	call _delay_ms
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'8'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'1'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	movlw D'6'
	bcf STATUS, RP0
	movwf param00_LCD_Comando
	call _LCD_Comando
	bcf PCLATH, 3
	bcf PCLATH, 4
	return
_LCD_Ini__end
_delay_ms__code
label_0001
	movlw D'142'
	bcf STATUS, RP0
	movwf param00_delay_ms+1
	nop
	nop
label_0002
	nop
	nop
	nop
	nop
	decfsz param00_delay_ms+1, 1
	goto label_0002
	nop
	decfsz param00_delay_ms, 1
	goto label_0001
	nop
	return
_delay_ms__end
	;;;;;;;;
	;;;;;;;;void Lee_Tecla(void)
_Lee_Tecla__code
	;;;;;;;;{
	;;;;;;;;    set_tris_b(11110000b);
	movlw D'240'
	bsf STATUS, RP0
	movwf TRISB
	;;;;;;;;    clear_bit(OPTION_REG,NOT_RBPU);  // habilita pull-ups
	bcf OPTION_REG, NOT_RBPU
	;;;;;;;;    output_port_b(0);
	bcf STATUS, RP0
	clrf PORTB
	;;;;;;;;    asm comf PORTB,W;    // Lee y complementa
	comf PORTB,W;    // Lee y complementa
	;;;;;;;;    asm movwf _Temp1;    // Lee y complementa (Columna)
	movwf _Temp1;    // Lee y complementa (Columna)
	;;;;;;;;    asm swapf _Temp1,f;   // Cambia alta por baja
	swapf _Temp1,f;   // Cambia alta por baja
	;;;;;;;;    Temp=0;
	clrf _Temp
	;;;;;;;;    while (!(Temp1 & 0x01))  // cuenta hasta que llegue a un bit set
label_0003
	bcf STATUS, RP0
	movf _Temp1, W
	andlw D'1'
	andlw 0xFF
	movlw 1
	btfss STATUS, Z
	movlw 0
	sublw 0
	btfsc STATUS, Z
	goto label_0004
	;;;;;;;;    {
	;;;;;;;;      Temp1>>=1;
	rrf _Temp1, W
	andlw D'127'
	movwf _Temp1
	;;;;;;;;      Temp++;
	incf _Temp, F
	;;;;;;;;    }
	;;;;;;;;    if (Temp<4)  // se ha pulsado
	goto label_0003
label_0004
	movlw D'4'
	bcf STATUS, RP0
	subwf _Temp, W
	movlw 1
	btfsc STATUS, C
	clrw
	sublw 0
	btfsc STATUS, Z
	goto label_0005
	;;;;;;;;    {
	;;;;;;;;//      Temp2=(~Temp) & 00000011b; // guardo la columna (comp para adecuar fila)
	;;;;;;;;      Temp2=Temp;   // Guardo columna
	movf _Temp, W
	movwf _Temp2
	;;;;;;;;      set_tris_b(00001111b);     // ahora la fila
	movlw D'15'
	bsf STATUS, RP0
	movwf TRISB
	;;;;;;;;      clear_bit(OPTION_REG,NOT_RBPU);  // habilita pull-ups
	bcf OPTION_REG, NOT_RBPU
	;;;;;;;;      output_port_b(0);
	bcf STATUS, RP0
	clrf PORTB
	;;;;;;;;      asm comf PORTB,W;    // Lee y complementa
	comf PORTB,W;    // Lee y complementa
	;;;;;;;;      asm movwf _Temp1;    // Lee y complementa (Fila)
	movwf _Temp1;    // Lee y complementa (Fila)
	;;;;;;;;      Temp=0;
	clrf _Temp
	;;;;;;;;      while (!(Temp1 & 0x01))  // cuenta hasta que llegue a un bit set
label_0006
	bcf STATUS, RP0
	movf _Temp1, W
	andlw D'1'
	andlw 0xFF
	movlw 1
	btfss STATUS, Z
	movlw 0
	sublw 0
	btfsc STATUS, Z
	goto label_0007
	;;;;;;;;      {
	;;;;;;;;        Temp1>>=1;
	rrf _Temp1, W
	andlw D'127'
	movwf _Temp1
	;;;;;;;;        Temp++;
	incf _Temp, F
	;;;;;;;;      }
	;;;;;;;;      if (Temp<4)  // Fila correcta
	goto label_0006
label_0007
	movlw D'4'
	bcf STATUS, RP0
	subwf _Temp, W
	movlw 1
	btfsc STATUS, C
	clrw
	sublw 0
	btfsc STATUS, Z
	goto label_0008
	;;;;;;;;      {
	;;;;;;;;//        Temp1=(~Temp) & 00000011b; // Guarda fila y trasloca bits
	;;;;;;;;        Temp1=Temp;
	movf _Temp, W
	movwf _Temp1
	;;;;;;;;        Tecla=(Temp2<<2)+Temp1;
	clrf _code_tmp_0000 
	movf _Temp2, W
	movwf _code_tmp_0001 
	rlf _code_tmp_0001 , F
	rlf _code_tmp_0001 , W
	andlw D'252'
	addwf _Temp1, W
	btfsc STATUS, C
	incf _code_tmp_0000 , F
	movwf _Tecla
	;;;;;;;;      }
	;;;;;;;;      else Tecla=0xFF;
	goto label_0009
label_0008
	movlw D'255'
	bcf STATUS, RP0
	movwf _Tecla
	;;;;;;;;    }
label_0009
	;;;;;;;;    else Tecla=0xFF;
	goto label_0010
label_0005
	movlw D'255'
	bcf STATUS, RP0
	movwf _Tecla
	;;;;;;;;}
label_0010
	return
_Lee_Tecla__end
	;;;;;;;;
	;;;;;;;;void I2C_Start(void)
_I2C_Start__code
	;;;;;;;;{
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  set_bit(SSPCON2,0);            // Envia Start
	bsf STATUS, RP0
	bsf _SSPCON2, D'0'
	;;;;;;;;  while (SSPCON2 & 00000001b);   // Mira que acabe el Start
label_0011
	bsf STATUS, RP0
	btfss _SSPCON2, 0
	goto label_0012
	;;;;;;;;}
	goto label_0011
label_0012
	return
_I2C_Start__end
	;;;;;;;;
	;;;;;;;;void I2C_Stop(void)
_I2C_Stop__code
	;;;;;;;;{
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  set_bit(SSPCON2,2);            // Envia Stop
	bsf STATUS, RP0
	bsf _SSPCON2, D'2'
	;;;;;;;;  while (SSPCON2 & 00000100b);   // Mira que acabe el Stop
label_0013
	bsf STATUS, RP0
	btfss _SSPCON2, 2
	goto label_0014
	;;;;;;;;}
	goto label_0013
label_0014
	return
_I2C_Stop__end
	;;;;;;;;
	;;;;;;;;void I2C_Envia(char dato)
_I2C_Envia__code
	;;;;;;;;{
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  SSPBUF=dato;                   // Envia el dato
	movf param00_I2C_Envia, W
	movwf _SSPBUF
	;;;;;;;;  while ((PIR1 & 00001000b)==0); // Espera que termine
label_0015
	bcf STATUS, RP0
	movf _PIR1, W
	andlw D'8'
	sublw D'0'
	movlw 1
	btfss STATUS, Z
	clrw
	sublw 0
	btfsc STATUS, Z
	goto label_0016
	;;;;;;;;}
	goto label_0015
label_0016
	return
_I2C_Envia__end
	;;;;;;;;
	;;;;;;;;char I2C_Recibe(void)
_I2C_Recibe__code
	;;;;;;;;{
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  set_bit(SSPCON2,3);            // Habilita la recepcion
	bsf STATUS, RP0
	bsf _SSPCON2, D'3'
	;;;;;;;;  while ((PIR1 & 00001000b)==0); // Espera que se haya recibido todo
label_0017
	bcf STATUS, RP0
	movf _PIR1, W
	andlw D'8'
	sublw D'0'
	movlw 1
	btfss STATUS, Z
	clrw
	sublw 0
	btfsc STATUS, Z
	goto label_0018
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	goto label_0017
label_0018
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  return(SSPBUF);                // Lee Tecla
	movf _SSPBUF, W
	return
	;;;;;;;;}
_I2C_Recibe__end
	;;;;;;;;
	;;;;;;;;void I2C_Ack(char valor)
_I2C_Ack__code
	;;;;;;;;{
	;;;;;;;;  clear_bit(PIR1,3);             // Limpia bit de int de SSP
	bcf STATUS, RP0
	bcf _PIR1, D'3'
	;;;;;;;;  if (valor) set_bit(SSPCON2,5); // _reconocimiento=1
	movf param00_I2C_Ack, W
	sublw 0
	btfsc STATUS, Z
	goto label_0019
	bsf STATUS, RP0
	bsf _SSPCON2, D'5'
	;;;;;;;;  else clear_bit(SSPCON2,5);     // _reconocimiento=0
	goto label_0020
label_0019
	bsf STATUS, RP0
	bcf _SSPCON2, D'5'
	;;;;;;;;  set_bit(SSPCON2,4);            // Envia reconocimiento
label_0020
	bsf STATUS, RP0
	bsf _SSPCON2, D'4'
	;;;;;;;;  while ((PIR1 & 00001000b)==0); // Espera que termine
label_0021
	bcf STATUS, RP0
	movf _PIR1, W
	andlw D'8'
	sublw D'0'
	movlw 1
	btfss STATUS, Z
	clrw
	sublw 0
	btfsc STATUS, Z
	goto label_0022
	;;;;;;;;}
	goto label_0021
label_0022
	return
_I2C_Ack__end
	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -