The answer is in the error ...
Code:ERROR: (wsave variable not found,) ERROR: (" Add:" wsave VAR BYTE $70 SYSTEM)
The answer is in the error ...
Code:ERROR: (wsave variable not found,) ERROR: (" Add:" wsave VAR BYTE $70 SYSTEM)
DT
Many Thanks Darrel for the answer.
Itt compiles fine now.
However, cam up another issue;
how can i get a string of chars, like i use in Hserin, for instance;
I Will Send to the pic "OK32Hugo" and then i want to compare the "ID" and the "Dados".Code:Hserin [wait("OK"),STR ID\2,str DAdos\4]
I'm trying to figure out the example that you gave int the
http://www.picbasic.co.uk/forum/show...8336#post28336
but i'm not getting there, can you help me here on this? Waht to i have to put in the
To Receive the data?Code:serialin: @ INT_RETURN
There are many ways you can do it. It depends on what you need.
If you want the main program to continue running while it's receiving data, then you'll need to use the buffer method as shown in that thread.
If you just want the main program to stop what it's doing and grab the serial data, then simply put your HSERIN in the serialin handler.
You should add a timeout if you do that though.
DT
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;
ThanksCode:'**************************************************************** '* 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
The best solution ... I've never found one of those.
Found things that "work" along the way, but there's always something better.
Don't know if this is better or not, but it is definitely different.
If nothing else, you should add the RXfail timeout to the HSERIN statement.Code:<font color="#000000"><b>ID </b><font color="#008000"><b>VAR BYTE </b></font><b>Interr</b>: <font color="#008000"><b>Hserin </b></font><font color="#800000"><b>100</b></font>,<b>RXfail</b>, [<b>wait</b>(<font color="#FF0000">"OK"</font>),<font color="#008000"><b>DEC2 </b></font><b>ID</b>, <font color="#008000"><b>str </b></font><b>DAdos</b>\<font color="#800000"><b>4</b></font>] <font color="#008000"><b>if </b></font><b>ID </b>= <font color="#800000"><b>32 </b></font><font color="#008000"><b>then </b></font><b>ARRAYREAD DAdos</b>, <font color="#800000"><b>4</b></font>,<b>No_Hugo</b>,[<b>WAIT</b>(<font color="#FF0000">"Hugo"</font>)] <font color="#008000"><b>high </b></font><b>led </b><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$fe</b></font>, <font color="#800000"><b>1 </b></font><font color="#008000"><b>lcdout </b></font><font color="#FF0000">" Teste USB" </font><font color="#008000"><b>lcdout </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>,<font color="#FF0000">"Recebido H " </font><b>No_Hugo</b>: <b>ARRAYREAD DAdos</b>, <font color="#800000"><b>4</b></font>,<b>No_LuLu</b>,[<b>WAIT</b>(<font color="#FF0000">"LuLu"</font>)] <font color="#008000"><b>low </b></font><b>led </b><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$fe</b></font>, <font color="#800000"><b>1 </b></font><font color="#008000"><b>lcdout </b></font><font color="#FF0000">" Teste USB" </font><font color="#008000"><b>lcdout </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>,<font color="#FF0000">"Recebido L " </font><b>No_LuLu</b>: <b>ARRAYREAD DAdos</b>, <font color="#800000"><b>2</b></font>,<b>NO_LH</b>,[<b>WAIT</b>(<font color="#FF0000">"LH"</font>)] <font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$fe</b></font>, <font color="#800000"><b>1 </b></font><font color="#008000"><b>lcdout </b></font><font color="#FF0000">" Teste USB" </font><font color="#008000"><b>lcdout </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>,<font color="#FF0000">"Recebido :"</font>,<font color="#008000"><b>STR </b></font><b>DADOS</b>\<font color="#800000"><b>4 </b></font><b>NO_LH</b>: <font color="#008000"><b>endif </b></font><b>RXfail</b>: <font color="#000080">@ INT_RETURN </font>
DT
ARRAYREAD/ARRAYWRITE are new in PBP 2.60.
I guess the RTFM would be section 5.3 (page 50) in the manual.
There haven't been any tutorials that I know of yet.
Essentially, ARRAYREAD is the same as a SERIN2.
But it works on data that is already in an Array, instead of data being received via RS232.
All the same modifiers work. WAIT DEC HEX BIN etc.
Instead of a timeout, you specify the number of bytes to check.
If it runs out of bytes before it satisfies the parameters, it jumps to the label. (ex. No_Hugo)
The way I used it makes it more like an IF statement for Strings.
hth,
DT
Bookmarks