历史上的今天
今天是:2025年03月10日(星期一)
2020年03月10日 | PIC16F1933点亮LCD1602(汇编)
2020-03-10 来源:eefocus
;
; 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 0x0020
delayCnt res 1
VAR20 res 1
VAR21 res 1
VAR29 res 1
VAR22 res 1
VAR23 res 1
VAR24 res 1
VAR27 res 1
VAR26 res 1
VAR25 res 1
sharebank udata_ovr 0x0070
TMP09 res 1
TMP08 res 1
TMP07 res 1
STK06 res 1
STK05 res 1
STK04 res 1
STK03 res 1
STK02 res 1
STK01 res 1
STK00 res 1
;----------------------------------------------------------------------
; Program Memory
;----------------------------------------------------------------------
org 0x0000 ; Reset vector
nop
goto sysboot
org 0x0004 ; Interrupt Service Routine (ISR)
retfie
sysboot 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_init
WHILE1
; 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
上一篇:PIC16F690 最简单的实例
下一篇:单片机独立按钮防止连按
史海拾趣
|
建立ModelSim SE 的Xilinx仿真库方法,从网上搜到的有很多,实践过其中几种,其中一种较简单的方法如下:1)当然是要安装ModelSim 和ISE 。 2)将ModelSim根目录下的modelsim.ini文件的只读属性去掉。3)在ModelSim命令窗口输入:compxlib -s mti_s ...… 查看全部问答> |
|
出现的问题:能接电话,不能打电话,发短信正常,收短信的内容不对。 我的操作如下: AT+CFUN=1 AT+CFUN=1 AT+COPS=0 AT+IPR=115200 &nbs ...… 查看全部问答> |
|
请教STM32的AD在多通道使用时候和单通道使用的时候的偏差问 手里有一个产品,使用到STM32的AD的两个通道,一个为Regular方式,阵发性打开,采样率为250HZ,另一个为Inject通道,每一秒钟检测一次,用以检测设备的电池电量。现在的现象是在没有开启regular方式的时候检测电池电量正常,一旦开启的regular ...… 查看全部问答> |
|
STM32 读取 NAND512W3A2CN6E 的ID为20 76 20 76.但是读取不到status。一直为0x00.应该为0xC0才对的。这是怎么回事呢?有遇到这个情况的吗?… 查看全部问答> |
|
在众多软件项目中,缺乏合理的进度安排是造成项目滞后的最主要原因,它比其他所有因素加起来的影响还要大。导致这种灾难如此普遍的原因是什么呢? 首先,我们对估算技术缺乏有效的研究,更加严肃地说,它反映了一种 ...… 查看全部问答> |




