Hi Again, and thanks for the replys.
Hi made this way, ad it works fine, however i don't have sure that is the best solutio;
Code:
'****************************************************************
'* Name : Teste Interrupt Serial.BAS *
'* Author : Hugo Oliveira *
'* Notice : Copyright (c) 2010 ProSystems *
'* : All Rights Reserved *
'* Date : 10-08-2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEFINE OSC 4
include "modedefs.bas"
INCLUDE "DT_INTS-14.bas"
include "ReEnterPBP.bas"
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RX_INT, _Interr, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE RX_INT ; enable external (INT) interrupts
' VARIÁVEIS
' ====================================================================
DADO var byte
DADOS var byte(4)
ID var byte(2)
wsave VAR BYTE $70 SYSTEM
' REGISTOS PINOUT 1 = IN; 0 = OUT
' ====================================================================
'76543210
TRISA = %00000001
TRISB = %00001111
TRISC = %10000000
TRISD = %00000000
TRISE = %00000000
ADCON1 = 7
' NOMES PINOUT
' ====================================================================
LED VAR PORTA.1
Botao var PORTA.0
TX Var PORTC.6
RX VAR PORTC.7
' DEFINIÇÕES
' ====================================================================
DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB
DEFINE LCD_DBIT 4 ' PORTB starting address
DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB
DEFINE LCD_RSBIT 3 ' LCD RS bit address
DEFINE LCD_EREG PORTB ' LCD E bit on PORTB
DEFINE LCD_EBIT 2 ' LCD E bit address
DEFINE LCD_BITS 4 ' LCD in 4-bit mode
DEFINE LCD_LINES 2 ' LCD has 2 rows
DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us
DEFINE LCD_DATAUS 50 ' Set data delay time in us
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h 'Testado 300-20h,600-20h,1200-20h,2400-20h,4800-24h,9600-24h,14400-24h,19200-24h,28800-24h
DEFINE HSER_BAUD 28800
DEFINE HSER_CLROERR 1
' INICIO PROGRAMA
' ====================================================================
Start:
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
HIGH LED
LCDOUT $fe, 1
lcdout " Teste Interrupt "
lcdout $FE,$C0," Por Hugo Oliveira"
pause 1000
Main:
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
goto Main
Interr:
Hserin [wait("OK"),STR ID\2,str DAdos\4] 'Testado 300-20h,600-20h,1200-20h,2400-20h,4800-24h,9600-24h,14400-24h,19200-24h,28800-24h
if id(0)="3" and id(1)="2" then
if DADOS(0)="H" and DADOS(1)="u" and DADOS(2)="g" and DADOS(3)="o" then
high led
LCDOUT $fe, 1
lcdout " Teste USB"
lcdout $FE,$C0,"Recebido H "
endif
if DADOS(0)="L" and DADOS(1)="u" and DADOS(2)="L" and DADOS(3)="u" then
low led
LCDOUT $fe, 1
lcdout " Teste USB"
lcdout $FE,$C0,"Recebido L "
endif
if DADOS(0)<>"L" and DADOS(0)<>"H" then
LCDOUT $fe, 1
lcdout " Teste USB"
lcdout $FE,$C0,"Recebido :",DADOS(0),DADOS(1),DADOS(2),DADOS(3)
endif
endif
@ INT_RETURN
END
Thanks
Bookmarks