-
Notifications
You must be signed in to change notification settings - Fork 0
/
pic752-contador-ascendente-y-descendente.pbp
137 lines (113 loc) · 4.12 KB
/
pic752-contador-ascendente-y-descendente.pbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
ASM_CONFIG_MCLRE_OFF; ;RA3 ENEABLE AS INPUT AND /MCLR TO VDD
CONFIGURATION_WORD_MCLRE_OFF
OSCCON = %00100100; 4 MHZ INTERNAL OSCILATOR
OSCTUNE = 0; RUNING AT THE CALIBRATED FRECUENCY
TRISA = %111000; RA0:RA2 SET AS OUTPUT AND RA3:RA5 SET AS INPUT
ANSELA = %010000; RA4 SET AS ANALOG
INTCON.7 = 0; DISABLE ALL INTERRUPTS
CM1CON0 =7; comparator 1 off
PORTA = 0;
T1CON = %10000101; TIMER 1 ENEABLE, EXTERNAL CLOCK T1CKL
LATA = 0; SWITCH DESACTIVATE
OPTION_REG.7 = 0; PULL UPS ENEABLE
WPUA = %001000; RA3 PULL UP ENEABLE
;--------------VARIABLES---------------------
;MI VAR BYTE;
;READ 0,timer;
TMR1L = 0;
TMR1H = 0;
CLOCK VAR WORD: C VAR BYTE:SEC VAR BYTE: MI VAR BYTE: HO VAR BYTE:S VAR BYTE;
LOOKI VAR BYTE[6]: LOOKO VAR BYTE[6]: IN VAR BYTE: OUT VAR BYTE: X VAR BYTE;
TIMER VAR WORD: COUN VAR WORD: LOOKI2 VAR BYTE[6]: LOOKO2 VAR BYTE[6];
COUN = 0;
TIMER = 0;
;------------STARTING PROGRAM-------------
PAUSE 40;
SI VAR PORTA.0; SERIAL DATA
CLK VAR PORTA.1; CLOCK
RS VAR PORTA.2; READ STROBE
SYMBOL M = 1;
;INITIALIZING THE LCD MODULE ACCORDING TO THE LCD DATASHEET
RS = 0;
SHIFTOUT SI,CLK,M,[$39]; 8 BIT DATA LENGTH, 2 LINES, INSTRUCTION TABLE 10
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$1C]; BS: 1/4, 2 LINE LCD
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$52]; BOOSTER OFF, CONTRAST C5, SET C4
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$69]; BS: 1/4, 2 LINE LCD
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$74]; SET CONTRAST C3, C2, C1
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$38]; SWITC BACK TO INSTRUCTION TABLE 0
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$0C];DISPLAY ON, CURSOR OFF, NO BLINK
PAUSEUS 27; 27 MICROSECOND
SHIFTOUT SI,CLK,M,[$01]; DELETE DISPLAY, CURSOR AT HOME
PAUSEUS 1080; 1080 MICROSECOND
SHIFTOUT SI,CLK,M,[$06]; CURSOR AUTO-INCREMENT
PAUSEUS 27; 27 MICROSECOND
RS = 1;
;-------MAIN METHOD---------------
SHIFTOUT SI,CLK,M,[$01]; CLEAR DISPLAY
PAUSEUS 1080;
SHIFTOUT SI,CLK,M,[$39]; $39 FOR NORMAL HEIGHT
PAUSEUS 27;
;WRITING ON THE FIRST LINE
RS=0
SHIFTOUT SI,CLK,M,[$80]; FIRST LINE DIRECTION
PAUSEUS 27;
;---------------------------------------------
RS=1; TO WRITE DATA
SHIFTOUT SI,CLK,M,[" Counter T1CKI "];
PAUSEUS 27;
RS = 0; TO WRITE A COMMAND
SHIFTOUT SI,CLK,M,[$C0];SECOND LINE DIRECTION
PAUSEUS 27;
RS = 1; TO WRITE A COMMAND
SHIFTOUT SI,CLK,M,[" "];
PAUSEUS 27;
;--------------------------------------------
MAIN:
GOSUB SHOW; GO TO LABEL SHOW
TIMER = TMR1L +(TMR1H*256); JOINING ADRESH AND ADRESL
GOSUB SHOW; GO TO LABEL SHOW
GOTO MAIN; GO TO LABEL MAIN
;----------MUESTRA TIEMPO---------------------------
SHOW:; LABEL SHOW
LOOKI = 0; CLEAR ARRAY VAR LOOKI
for x = 0 to 4; LOOP FOR VARIABLE X, STARTING X = 0;
looki[x] = timer dig x; SAVE DIGIT X OF TIMER IN LOOKI[X]
next x; NEXT LOOP
COUN = 65535 - TIMER;
for x = 0 to 4; LOOP FOR VARIABLE X, STARTING X = 0;
looki2[x] = COUN dig x; SAVE DIGIT X OF TIMER IN LOOKI[X]
next x; NEXT LOOP
FOR X = 0 TO 4; LOOP FOR VARIABLE X, STARTING X = 0;
IN = LOOKI[X]; SAVE THE ARRAY VARIABLE "LOOKI[X]" IN VARIABLE "IN"
LOOKUP IN, ["0123456789ABCDEF"], OUT; DECODING VAR "IN" TO VAR "OUT"
LOOKO[X] = OUT; SAVE THE VARIABLE "OUT" IN ARRAY VARIABLE "LOOKO[X]"
NEXT X; NEXT LOOP
FOR X = 0 TO 4; LOOP FOR VARIABLE X, STARTING X = 0;
IN = LOOKI2[X]; SAVE THE ARRAY VARIABLE "LOOKI[X]" IN VARIABLE "IN"
LOOKUP IN, ["0123456789ABCDEF"], OUT; DECODING VAR "IN" TO VAR "OUT"
LOOKO2[X] = OUT; SAVE THE VARIABLE "OUT" IN ARRAY VARIABLE "LOOKO[X]"
NEXT X; NEXT LOOP
GOSUB MESSAGE;GO TO LABEL MESSAGE
RETURN; RETURN TO CALLED
;-----------------------
MESSAGE:; LABEL MESSAGE
RS=0
SHIFTOUT SI,CLK,M,[$80]; FIRST LINE DIRECTION
PAUSEUS 27;
RS=1; TO WRITE DATA
SHIFTOUT SI,CLK,M,["COUNT = ",LOOKO[4],LOOKO[3],LOOKO[2],LOOKO[1],LOOKO[0]," "];
PAUSEUS 27;
RS = 0; TO WRITE A COMMAND
SHIFTOUT SI,CLK,M,[$C0];SECOND LINE DIRECTION
PAUSEUS 27;
RS = 1; TO WRITE A COMMAND
SHIFTOUT SI,CLK,M,["COUNT2 = ",LOOKO2[4],LOOKO2[3],LOOKO2[2],LOOKO2[1],LOOKO2[0]," "];
PAUSEUS 27;
RETURN; RETURN TO CALLED
END; END OF CODE