LCD INIT MSP430 and Touch Screen
Hi
This is my assembler code for MSP430F2274 of Texas Instruments, i hope it can help somebody and i have a question about the touch screen conection, because I use the TSC2007 with terminals X+ Y+ X- Y- and i don't know how to connect it with the LCD
NAME main ; module name
PUBLIC main ; make the main label vissible
; outside this module
#include "msp430x22x4.h" ; #define controlled include file
#define PAUSA R15
#define CE 01H
#define CD 02H
#define RES 04H
ORG 0200H
DATO DS 2
COORD DS 2
;-------------------------------------------------------------------------------
ORG 0x8000 ;Inicio del programa
;-------------------------------------------------------------------------------
main
RESET MOV.W #0x600,SP ; Inicialización del stackpointer
MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Watchdog timer detenido
MOV.B &CALBC1_16MHZ,&BCSCTL1 ; DCO en 16 MHz
MOV.B &CALDCO_16MHZ,&DCOCTL
MICRO_INIT MOV.B #0FFH,&P1DIR ; Configuración de los puertos
MOV.B #0FFH,&P2DIR
MOV.B #0FFH,&P3DIR
MOV.B #0FFH,&P4DIR
VAL_INI CLR.B &P4OUT
BIS.B #CE,&P2OUT
BIS.B #RES,&P2OUT
OTROS_INIT CALL #LCD_INIT ;Inicialización LCD Gráfica
;-------------------------------------------------------------------------------
;PROGRAMA PRINCIPAL
;-------------------------------------------------------------------------------
PRINCIPAL MOV #000H,COORD
CALL #COORDENAD
MOV #0C00H,R10
BORRAR MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
DEC R10
JNZ BORRAR
MOV #1400H,R10
PONER MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
DEC R10
JNZ PONER
MOV #01C2H,COORD
CALL #COORDENAD
MOV #LETRERO1,R4
CALL #IMP_LET
GRAFICO MOV #0C82H,COORD
CALL #COORDENAD
CLR R6
CLR R7
MOV #POLI,R5
SIGUE MOV.B @R5,&P4OUT
CMP #100,R6
JEQ FIN_P
CMP #09H,R7
JEQ AJUSTE
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
INC R7
INC R5
JMP SIGUE
AJUSTE CLR R7
INC R6
ADD #1EH,COORD
CALL #COORDENAD
CALL #TIEMPOL
JMP SIGUE
FIN_P CALL #PAUSA2S
MOV #01C2H,COORD
CALL #COORDENAD
MOV #1EH,R7
BORRA1 MOV.B #00H,&P4OUT
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
CALL #TIEMPOL
DEC R7
JNZ BORRA1
MOV #0C82H,COORD
CALL #COORDENAD
CLR R6
CLR R7
MOV #POLI,R5
SIGUE2 MOV.B #00H,&P4OUT
CMP #100,R6
JEQ JUMP
CMP #09H,R7
JEQ AJUSTE2
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
INC R7
JMP SIGUE2
AJUSTE2 CLR R7
INC R6
ADD #1EH,COORD
CALL #COORDENAD
CALL #TIEMPOL
JMP SIGUE2
JUMP JMP JUMP
;-------------------------------------------------------------------------------
;SUBRUTINAS
;-------------------------------------------------------------------------------
LCD_INIT BIC.B #RES,&P2OUT
MOV #100,PAUSA
NEXT DEC PAUSA
JNZ NEXT
BIS.B #RES,&P2OUT
MOV.B #080H,&P4OUT
CALL #COMANDO
MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #00CH,&P4OUT
CALL #DAT
MOV.B #042H,&P4OUT
CALL #COMANDO
MOV.B #030,&P4OUT
CALL #DAT
MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #043H,&P4OUT
CALL #COMANDO
MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #040H,&P4OUT
CALL #COMANDO
MOV.B #030,&P4OUT
CALL #DAT
MOV.B #000H,&P4OUT
CALL #DAT
MOV.B #041H,&P4OUT
CALL #COMANDO
MOV.B #09CH,&P4OUT
CALL #COMANDO
MOV.B #081H,&P4OUT
CALL #COMANDO
RET
COORDENAD MOV.B COORD,&P4OUT
CALL #DAT
SWPB COORD
MOV.B COORD,&P4OUT
CALL #DAT
MOV.B #024H,&P4OUT
CALL #COMANDO
SWPB COORD
RET
IMP_LET MOV.B @R4+,DATO
AND #00FFH,DATO
CMP #080H,DATO
JEQ Salir
MOV.B DATO,&P4OUT
CALL #DAT
MOV.B #0C0H,&P4OUT
CALL #COMANDO
BR #IMP_LET
Salir RET
DAT CALL #TIEMPO
BIC.B #CD,&P2OUT
CALL #CHIP_E
RET
COMANDO CALL #TIEMPO
BIS.B #CD,&P2OUT
CALL #CHIP_E
RET
CHIP_E NOP
NOP
NOP
BIC.B #CE,&P2OUT
NOP
NOP
NOP
NOP
NOP
NOP
BIS.B #CE,&P2OUT
NOP
NOP
NOP
RET
TIEMPO MOV #16,R9
T1 DEC R9
JNZ T1
RET
TIEMPOL MOV #60000,R9
T2 DEC R9
JNZ T2
RET
PAUSA2S MOV #1000,R11
P3 MOV #1000,R10
P2 MOV #8,R9
P1 DEC R9
JNZ P1
DEC R10
JNZ P2
DEC R11
JNZ P3
RET
;-------------------------------------------------------------------------------
;TABLAS
;-------------------------------------------------------------------------------
LETRERO1 DB 29H,'NSTITUTO',00H,30H,'OLIT',62H,'CNICO',00H,2EH,'ACIONAL',80H
POLI DB 00H,00H,04H,00H,00H,00H,01H,0F8H,00H
DB 00H,00H,3FH,00H,00H,00H,01H,0EEH,00H
DB 00H,01H,0B9H,0C0H,00H,00H,61H,0E3H,00H
DB 00H,03H,0B8H,0F0H,00H,03H,0F9H,0E1H,00H
DB 00H,1BH,0B8H,0B8H,00H,03H,0E7H,0E1H,00H
DB 00H,0DBH,0B8H,0A6H,00H,03H,0F3H,0E1H,00H
DB 01H,0DBH,0B8H,0AAH,07H,83H,0F1H,0E1H,00H
DB 01H,0DBH,0B8H,0AAH,03FH,0E3H,0F9H,0E1H,00H
DB 01H,0DBH,0A6H,0AAH,0FFH,0BBH,0FDH,0E1H,00H
DB 01H,0DBH,019H,0BAH,0FFH,08BH,0FFH,0E1H,00H;10
DB 01H,0D0H,0B8H,0E6H,0F7H,08BH,0FFH,0E1H,00H
DB 01H,083H,0B8H,0E6H,0E3H,08BH,0FFH,0E1H,00H
DB 00H,05BH,0B8H,0E1H,0E3H,08BH,0FFH,0E1H,00H
DB 01H,0DBH,0B8H,0E0H,0E3H,08BH,0FFH,0E1H,00H
DB 01H,0DBH,0B8H,0E0H,0E3H,08BH,0DFH,0E1H,00H
DB 01H,0DBH,0B8H,0E0H,0F7H,08BH,0CFH,0E1H,00H
DB 01H,0DBH,0A6H,0E0H,0FFH,08BH,0C7H,0E1H,00H
DB 01H,0DBH,009H,0E0H,0FFH,08BH,0C3H,0E1H,00H
DB 01H,0D0H,0B8H,0E0H,0FEH,00BH,0C3H,0E1H,00H
DB 01H,083H,0B8H,0E0H,0F8H,01BH,0C1H,0E1H,00H;20
DB 00H,01BH,0B8H,0E0H,0E6H,01BH,0C0H,0E9H,00H
DB 01H,0DBH,0B8H,0E0H,0E1H,073H,0C0H,0FDH,00H
DB 01H,0DBH,0B8H,0E0H,0E1H,003H,0CFH,0FFH,00H
DB 01H,0DBH,0B8H,0E0H,0E1H,007H,0FFH,0FFH,080H
DB 01H,0DBH,0B8H,0E0H,0E1H,03FH,0FCH,003H,0C0H;25
DB 01H,0DBH,0A6H,0E0H,0E3H,0FFH,0C0H,0C0H,0C0H
DB 01H,0D8H,019H,0E1H,0FFH,0F8H,007H,0E1H,0C0H
DB 01H,083H,0B8H,0E7H,0FFH,080H,03CH,01FH,080H
DB 00H,05BH,0B8H,0FFH,0F0H,00BH,0FEH,01CH,000H
DB 05H,0DBH,0B9H,0FFH,000H,0DBH,0FEH,03FH,000H;30
DB 05H,0DBH,0B9H,0C0H,001H,09BH,0FEH,07CH,0C0H
DB 01H,0DBH,0B0H,014H,007H,0B5H,0FFH,0FEH,020H
DB 01H,0DBH,0B9H,0D4H,0FFH,034H,0FFH,0FBH,090H
DB 01H,0DBH,0A1H,0D7H,003H,068H,0FFH,0F0H,070H
DB 01H,0D2H,009H,0F4H,007H,068H,07FH,0E0H,020H;35
DB 00H,009H,0B9H,01AH,006H,050H,07FH,0E0H,040H
DB 09H,0DBH,0B9H,0F9H,00EH,0D0H,07FH,0B8H,080H
DB 1DH,0DBH,0B9H,00EH,0ECH,0A0H,03FH,08FH,000H
DB 1DH,0DBH,0B9H,0FEH,01DH,0A0H,03FH,083H,000H
DB 0DH,0DBH,0B8H,097H,0B9H,040H,03FH,09FH,0E0H;40
DB 05H,0DBH,0B8H,09BH,0FBH,040H,03FH,0FFH,018H
DB 01H,0DBH,0BFH,0FFH,0F2H,080H,03FH,0FFH,008H
DB 01H,0D8H,039H,098H,0FEH,0C0H,03FH,0FFH,0C8H
DB 00H,001H,0C6H,0F7H,07DH,0F0H,03FH,0FCH,078H
DB 01H,0DFH,039H,097H,0DEH,0FEH,03FH,0F8H,038H;45
DB 7DH,0D8H,0FCH,0AFH,04EH,071H,0FFH,0EFH,0E0H
DB 7DH,0E7H,083H,06CH,0E7H,07EH,01FH,0C1H,000H
DB 7DH,09BH,0E8H,093H,0FFH,0FFH,0FFH,0C1H,000H
DB 3EH,07BH,0BFH,0FFH,0C0H,01FH,0EFH,0C1H,000H
DB 0DH,0DBH,0BFH,000H,03FH,0FFH,0D7H,0FFH,0E0H;50
DB 13H,0FFH,0FFH,0FFH,0F7H,0FFH,0BBH,0FFH,038H
DB 3FH,0CFH,0F0H,0FFH,0F3H,0FFH,0BBH,0FFH,008H
DB 05H,0CFH,0FEH,007H,0F0H,001H,05DH,0FFH,088H
DB 0CH,0C0H,001H,0F3H,0F3H,0FEH,0FEH,0F8H,078H
DB 16H,060H,006H,093H,0E7H,0FFH,01EH,0FFH,080H;55
DB 6FH,02FH,0FCH,09FH,0E7H,071H,01EH,0C0H,080H
DB 0EFH,0AFH,004H,0FFH,0E7H,071H,01EH,0C0H,080H
DB 0EFH,0AFH,01CH,083H,0C7H,061H,01EH,0C0H,080H
DB 2FH,0AFH,034H,0F0H,0D6H,0E1H,01EH,0FFH,080H
DB 17H,0AFH,0E2H,00EH,072H,0E1H,01EH,0F0H,040H;60
DB 13H,0AFH,0C1H,003H,0BAH,0C1H,03EH,0F8H,030H
DB 13H,0AFH,000H,0F0H,07BH,041H,03EH,0FFH,0F8H
DB 13H,0A7H,028H,0FEH,01DH,041H,03EH,0FEH,008H
DB 17H,0A6H,051H,0E7H,08DH,061H,03EH,0DEH,008H
DB 1FH,0B6H,059H,0ECH,046H,0A1H,03EH,0C3H,0F0H;65
DB 2FH,0B6H,07FH,0EFH,0B6H,0A1H,03EH,0C3H,000H
DB 6FH,0B2H,0D3H,0EDH,056H,0D1H,07EH,0FEH,000H
DB 6DH,0B2H,07FH,0FFH,097H,051H,07EH,0FFH,000H
DB 69H,0BBH,057H,0D8H,017H,069H,07EH,0E1H,080H
DB 2FH,0BBH,007H,0DCH,053H,0A9H,07EH,0F0H,0C0H;70
DB 11H,0B9H,087H,0F8H,093H,0A9H,0FEH,0FFH,0E0H
DB 11H,0BDH,087H,041H,021H,0B5H,0FEH,0F8H,020H
DB 13H,0BCH,0CEH,0FEH,0C1H,0D5H,0FEH,078H,020H
DB 17H,0BCH,0F0H,081H,080H,0BAH,0FEH,01FH,0E0H
DB 17H,0BEH,06EH,0FEH,000H,0EAH,0FEH,0F8H,000H;75
DB 17H,0DEH,05DH,000H,000H,0EEH,0FEH,0F8H,000H
DB 17H,05FH,03BH,000H,000H,076H,0FEH,08CH,000H
DB 16H,05FH,0B3H,000H,000H,076H,0FEH,086H,000H
DB 13H,0FFH,097H,000H,000H,07EH,0FEH,083H,000H
DB 10H,05FH,0C7H,000H,000H,07EH,0F6H,0C1H,000H;80
DB 10H,07FH,0E7H,080H,000H,07EH,0E2H,0FFH,000H
DB 10H,0BFH,0F1H,0C0H,000H,0FEH,0E1H,0C1H,000H
DB 10H,0BFH,0F8H,0F0H,003H,0FEH,0FFH,0C3H,000H
DB 07FH,0F3H,0FCH,0EFH,01FH,0FEH,0E1H,0FEH,000H
DB 0B0H,051H,0FEH,00FH,0F3H,0FEH,0F1H,040H,000H;85
DB 0DFH,09FH,0FFH,080H,00FH,0FEH,0F1H,060H,000H
DB 60H,063H,0FFH,0F0H,0EFH,0FEH,0F9H,020H,000H
DB 1FH,083H,0FFH,0FFH,0FFH,0FDH,0FDH,030H,000H
DB 00H,007H,0DFH,0FFH,0FFH,0FAH,003H,0F0H,000H
DB 00H,007H,08FH,0FFH,0FFH,0FDH,0FFH,090H,000H;90
DB 00H,007H,087H,0FFH,0FFH,0B9H,001H,060H,000H
DB 00H,003H,08FH,0FFH,0FEH,03CH,0FEH,040H,000H
DB 00H,003H,0FFH,01FH,0FFH,0FEH,000H,080H,000H
DB 00H,000H,00FH,01EH,01EH,01FH,0FFH,000H,000H
DB 00H,000H,00FH,01EH,01EH,00EH,030H,000H,000H;95
DB 00H,000H,00EH,01EH,01EH,00FH,0C0H,000H,000H
DB 00H,000H,007H,0FEH,01EH,008H,000H,000H,000H
DB 00H,000H,000H,01EH,01EH,008H,000H,000H,000H
DB 00H,000H,000H,00FH,0FEH,018H,000H,000H,000H
DB 00H,000H,000H,000H,00FH,0F0H,000H,000H,000H
;-------------------------------------------------------------------------------
;VECTORES DE INTERRUPCION
;-------------------------------------------------------------------------------
ORG 0FFFEH ; MSP430 RESET Vector
DW RESET ;
END
END MAIN