PIC16F1933点亮LCD1602(汇编)
来源:互联网 发布:mac系统怎么看电脑空间 编辑:程序博客网 时间:2024/05/16 05:39
;; TEST-GPIO;; FileName: main.S; Dependencies: p16f1933.h;; Processor: PIC16F1933;; Complier: GPASM;; Company: xx;; Author: Perry.Peng@xx.com;; just do a demonstration of pic16f1933.;; Features used:; - GPIO; - Timer1;; Description:; demo program.;; Notes:; - list p=16f1933, r=dec, f=inhx32, w=0 errorlevel -302 ; suppress message 302 from list file include "p16f1933.inc"; nolist; ---------------------------------------------------------------------; Configuration Bits; ---------------------------------------------------------------------#define _DEBUG 0xfeff __config _CONFIG1, _WDTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _FOSC_INTOSC & _CLKOUTEN_ON __config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _LVP_ON & _DEBUG;#define LCD_PIN_RS 7;#define LCD_PIN_RW 6;#define LCD_PIN_EP 5#define LCD_PIN_RS 3#define LCD_PIN_RW 4#define LCD_PIN_EP 5#define LCD_WR_CMD 0#define LCD_WR_DATA (1 << LCD_PIN_RS)#define LCD_RD_CMD (1 << LCD_PIN_RW)#define LCD_RD_DATA ((1 << LCD_PIN_RS) | (1 << LCD_PIN_RW))#define LCD_EP_MASK (1 << LCD_PIN_EP)#define LCD_CFG_BITS 0x28; Instructs gpasm that it should generate an error if there is any; use of the given RAM locations.;----------------------------------------------------------------------; Variables;----------------------------------------------------------------------.data udata 0x0020delayCnt res 1VAR20 res 1VAR21 res 1VAR29 res 1VAR22 res 1VAR23 res 1VAR24 res 1VAR27 res 1VAR26 res 1VAR25 res 1sharebank udata_ovr 0x0070TMP09 res 1TMP08 res 1TMP07 res 1STK06 res 1STK05 res 1STK04 res 1STK03 res 1STK02 res 1STK01 res 1STK00 res 1;----------------------------------------------------------------------; Program Memory;---------------------------------------------------------------------- org 0x0000 ; Reset vector nop goto sysboot org 0x0004 ; Interrupt Service Routine (ISR) retfiesysboot banksel OSCCON; SPLLEN IRCF3 IRCF2 IRCF1 IRCF0 UNIMP SCS1 SCS0; 4xPLL Oscillator Select bits N/A 1x Internal oscillator; 4xPLL 1111 = 16MHz HF N/A 01 timer1 osc; 4xPLL 1110 = 8MHz or (32MHz) N/A 00 use CONFIG bits.; 4xPLL 1101 = 4MHz; 4xPLL 1100 = 2MHz; 4xPLL 1011 = 1MHz; 4xPLL 1010 = 500kHz; 4xPLL 1001 = 250kHz; 4xPLL 1000 = 125kHz; 4xPLL 0111 = 500kHz MF (default); 4xPLL 0110 = 250kHz MF; ...; 4xPLL 0011 = 31.25kHz HF; 4xPLL 0010 = 31.25kHz MF; 4xPLL 000x = 31kHz LF; movlw 0xf3 ; 8MHz [x 4xPLL] = 32MHz movlw 0x6a ; 4MHz movwf OSCCON banksel ANSELA clrf ANSELA clrf ANSELB banksel TRISA clrf TRISA bcf TRISC, LCD_PIN_RS bcf TRISC, LCD_PIN_RW bcf TRISC, LCD_PIN_EP banksel PORTA clrf PORTA; call _lcd_initWHILE1; banksel PORTA; movf PORTA, W; xorlw 0x20; movwf PORTA movlw 0x20 movwf STK01 movlw 0x01 movwf STK00 movlw 0x05 call _lcd_display_char movlw 0x81 clrf STK00 call _lcd_write movlw 0x33 bsf STK00, 0 call _lcd_write goto WHILE1 return_lcd_display_char movf STK00, F btfss STATUS, Z iorlw 0x40 iorlw 0x80 clrf STK00 call _lcd_write movf STK01, W bsf STK00, 0 call _lcd_write return_lcd_read movwf TMP07 banksel TRISB movlw 0x0f iorwf TRISB, F banksel PORTC bcf PORTC, LCD_PIN_RS btfsc TMP07, 0 bsf PORTC, LCD_PIN_RS bsf PORTC, LCD_PIN_RW bsf PORTC, LCD_PIN_EP ; pull high ep pin. nop swapf PORTB, W bcf PORTC, LCD_PIN_EP ; pull low ep pin. ;bcf PORTC, LCD_PIN_RW andlw 0xf0 movwf TMP08 ;bcf PORTC, LCD_PIN_RS ;btfsc TMP07, 0 ;bsf PORTC, LCD_PIN_RS ;bsf PORTC, LCD_PIN_RW bsf PORTC, LCD_PIN_EP nop movf PORTB, W bcf PORTC, LCD_PIN_EP bcf PORTC, LCD_PIN_RW andlw 0x0f iorwf TMP08, F movf TMP08, W return_lcd_write movwf TMP09 btfsc STK00, 1 goto $ + 5 clrw call _lcd_read btfsc TMP08, 7 goto $ - 3 banksel PORTB clrf PORTB banksel TRISB movlw 0xf0 andwf TRISB, F banksel PORTC bcf PORTC, LCD_PIN_RS btfsc STK00, 0 bsf PORTC, LCD_PIN_RS bcf PORTC, LCD_PIN_RW swapf TMP09, W movwf PORTB bsf PORTC, LCD_PIN_EP ; pull high ep pin. nop nop bcf PORTC, LCD_PIN_EP ; pull low ep pin. clrf PORTB ;bcf PORTC, LCD_PIN_RS ;btfsc STK00, 0 ;bsf PORTC, LCD_PIN_RS ;bcf PORTC, LCD_PIN_RW movf TMP09, W movwf PORTB bsf PORTC, LCD_PIN_EP ; pull high ep pin. nop nop bcf PORTC, LCD_PIN_EP ; pull low ep pin. clrf PORTB bcf PORTC, LCD_PIN_RS return_lcd_init movlw 0x0a call _delayMs clrf STK00 bsf STK00, 1 ; no check busy flag. movlw LCD_CFG_BITS call _lcd_write movlw 0x1f call _delayMs movlw LCD_CFG_BITS call _lcd_write movlw 0x08 call _delayMs ;movlw LCD_CFG_BITS ;call _lcd_write clrf STK00 ; check busy flag. movlw LCD_CFG_BITS call _lcd_write movlw 0x08 call _delayMs movlw 0x08 ; lcd_set_display_off call _lcd_write movlw 0x01 ; lcd_clear call _lcd_write movlw 0x04 ; lcd_set_cur_stop call _lcd_write movlw 0x0c ; lcd_set_display_on call _lcd_write movlw 0x35 call _delayMs return_delayMs banksel VAR20 movwf VAR20_00108_DS_ banksel VAR20 decf VAR20,F movf VAR20,W btfsc STATUS,2 goto _00111_DS_ movlw 0xfa movwf VAR21_00105_DS_ banksel VAR21 decf VAR21,F movf VAR21,W btfsc STATUS,2 goto _00108_DS_ goto _00105_DS__00111_DS_ returnlcd_display_string1delayMs1 banksel delayCnt movwf delayCntdelayMs_l1 clrwdelayMs_l2 addlw 0x01 btfss STATUS, 0 goto delayMs_l2 decfsz delayCnt, F goto delayMs_l1 returndelayUs movwf STK05 incfsz STK05, F goto $ - 1 return;----------------------------------------------------------------------; Program messages;----------------------------------------------------------------------string1 retlw 0x57 retlw 0x0a retlw 0x00string2 retlw 0x45 retlw 0x0a retlw 0x00;----------------------------------------------------------------------; End of program;---------------------------------------------------------------------- end
0 0
- PIC16F1933点亮LCD1602(汇编)
- ok210汇编点亮LED灯
- 点亮LED——汇编
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- LCD1602
- lcd1602
- LCD1602
- lcd1602
- 一步步点亮LED3_从零开始手写汇编点亮LED
- 使用汇编代码点亮一个LED灯
- mini2440之汇编点亮一个led
- hadoop中ssh免密码登录设置不成功
- .net面试题
- Java中10内0奇数的和
- 为什么`forward_list`不支持`push_back`操作?
- MySQL连接数据库命令
- PIC16F1933点亮LCD1602(汇编)
- python 中 替换json不认识的格式
- 布尔教育2016最新php教程 PHP基础班+PHP大师班视频教程
- VC常用数据类型与转换
- Java中100以内同时被3和5整除的数,输出
- 05-树8 堆中的路径 (25分)
- JVM类型以及编译器模式
- Java中引用String 转换为char数组
- 1.51单片机 PCB的绘制