-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
127 lines (105 loc) · 4.19 KB
/
main.asm
File metadata and controls
127 lines (105 loc) · 4.19 KB
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
;====================================================================
; Main.asm file generated by New Project wizard
;
; Created: Thu Oct 27 2016
; Processor: PIC16F688
; Compiler: MPASM (Proteus)
;====================================================================
;====================================================================
; DEFINITIONS
;====================================================================
#include p16f688.inc ; Include register definition file;; __config 0xFFD4
#include "C:\Users\Bruno\git\Attendant\lcdModule\lcdMacros.inc"
__CONFIG _FOSC_INTOSCIO & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON
;====================================================================
; VARIABLES
;====================================================================
; Definitions for LCD controls
dataPort EQU PORTC
ctrlPort EQU PORTA
i EQU 0x20 ; Index for loop
j EQU 0x21 ; Index for loop
hi EQU 0x22 ; Most significant nibble from data/command
lo EQU 0x23 ; Least significant nibble from data/command
ticketType EQU 0x24
ticketChar0 EQU 0x25 ; Next ticket to be called
ticketChar1 EQU 0x26
ticketChar2 EQU 0x27
guicheNum EQU 0x28
#define rs ctrlPort, 0 ; R/S (Data/Command)
#define en ctrlPort, 1 ; Enable
#define btn1 ctrlPort, 4 ; Button 1
#define btn2 ctrlPort, 5 ; Button 2
;====================================================================
; RESET and INTERRUPT VECTORS
;====================================================================
; Reset Vector
ORG 0x0000
GOTO setup
; Interrupt Vector
ORG 0x0004
CALL intExecute ; routine located at btnModule/btnFunctions
RETFIE
;====================================================================
; CODE SEGMENT
;====================================================================
#include "C:\Users\Bruno\git\Attendant\lcdModule\lcdFunctions.inc"
#include "C:\Users\Bruno\git\Attendant\lcdModule\lcdMessages.inc"
#include "C:\Users\Bruno\git\Attendant\btnModule\btnFunctions.inc"
#include "C:\Users\Bruno\git\Attendant\serialModule\serialModule.inc"
#include "C:\Users\Bruno\git\Attendant\serialModule\commandModule.inc"
#include "C:\Users\Bruno\git\Attendant\serialModule\connectModule.inc"
setup:
; PIC pre configurations
BANKSEL CMCON0 ; Bank 1 selction
MOVLW 0x07
MOVWF CMCON0 ; Disabling comparators
BANKSEL ANSEL
CLRF ANSEL ; Disabling analog I/O
MOVLW B'111000'; RA[0..2]=output, RA[3..5]=input
MOVWF TRISA
MOVLW B'110000'; RC[0..3]=output, RC[4..5]=input
MOVWF TRISC
BCF OPTION_REG,7; notRAPU = Activate internal pull-up from PORTA
MOVLW B'110000'
MOVWF WPUA ; Weak pullup for RA5 e RA4
BANKSEL dataPort; Bank 0 selection
CLRF dataPort ; Data purposes
CLRF ctrlPort ; Control purposes
CALL lcdInit ; Execute LCD display init sequence
BSF INTCON, GIE ; Global Interrupt Enable Bit
BANKSEL IOCA ; Bank 1 selection
MOVLW B'110000'
MOVWF IOCA ; Interrupt on change active on RA5 and RA4
BSF INTCON, RAIE; PORTA change interrupt Enable bit
BCF INTCON, RAIF; Clearing RAIF Flag
MOVLW 0x70
MOVWF OSCCON ; set for 8-MHz internal clock
BANKSEL ctrlPort
; Configuring USART
MOVLW d'103' ;9600 baud
MOVWF SPBRG
BSF PIR1, RCIF ;set RX ok interrupt
BSF RCSTA, SPEN ;serial port enable
BSF RCSTA, CREN ;continuous RX enable
BCF TXSTA, SYNC ;asynchronous mode
BSF TXSTA, TXEN ;enable transmitter
MOVLW 'Z' ; Init ticketChar0 as Z
MOVWF ticketChar0
MOVLW '5' ; Init guiche number
MOVWF guicheNum
CALL delay
CALL delay
CALL delay
CALL delay
CALL connectWifi
CALL helloMessage
GOTO loop
;====================================================================
; MAIN LOOP
;====================================================================
loop:
CALL delay
GOTO loop
;====================================================================
END