Hi SHUSH,
The SCID is never really clear, if you read it it will have the recently recieved byte in it. If you write to it the byte will be sent (assuming you have everything setup which you have if you can send 1 byte)
To transmit a string write to the SCID one byte at a time waiting for the TDRE bit of SCIxS1 register to be set before each byte.
To recieve a string read SCID everytime you read RDRF in SCIxS1 as a 1.
Simple as that!
Regards David
Hello Shai,
After receiving each SCI character, you need to clear the the RDRF flag ready for the next character - I suspect that this may not be occurring for some reason. It would help if you could post your SCI receive code.
Regards,
Mac
/*** ===================================================================** Interrupt handler : isrVsci1rx**** Description :** User interrupt service routine. ** Parameters : None** Returns : Nothing** ===================================================================*/__interrupt void isrVsci1rx(void){ int i=0,j=0; //DisableInterrupts; command_in[i]=SCI1D; //READ the first char in the string //for (j=0;j<1000;j++){}; //delay /* READ the other chars in the string chain */ while (SCI1S1_RDRF==TRUE){ command_in[i]=SCI1D; ++i; //for (j=0;j<500;j++){}; //delay } /* ***************************************** */ /* put in the end of the string "/r/n" to recognize end of string */ ++i; command_in[i]='/'; ++i; command_in[i]='r'; ++i; command_in[i]='/'; ++i; command_in[i]='n'; /* *************************************************************** */ /* this part is for checking WRITE the string that READ before */ i=0; while (command_in[i]!='/'&&command_in[i+1]!='r'&&command_in[i+2]!='/'&&command_in[i+3]!='n'){ a_last1=command_in[i]; AS1_SendChar(a_last1); //for (j=0;j<500;j++){}; //delay ++i; } //EnableInterrupts; }/* end of isrVsci1rx */This code is using the AS1_SendChar procedure , here is the code of that procedure :byte AS1_SendChar(AS1_TComData Chr){ if(!SCI1S1_TDRE) /* Is the transmitter empty— */ return ERR_TXFULL; /* If no then error */ SCI1D = (byte)Chr; return ERR_OK; /* OK */}
Message Edited by Alban on 2006-08-21 12:35 PM
Regards,
Mac
Message Edited by bigmac on 2006-08-26 06:20 AM
Hi SHUSH,
You have gone about this quite incorrectly.
The way you have written it would be roughly correct if you were not using interrupts.
If you use interrupts you should be simply reading SCI1S1 first and then copying SCID into your buffer then exit. Do the rest of the housekeeping in the background.
Also finding the transmit buffer not empty is not an error, it just means you have to wait. The data dribbles out of the serial port much slower than you can throw the data at it!
Regards David
SHUSH,
This serial driver app note was written for a different micro, but you can directly use 99% and just modify it for the -AW's registers. It works great.
-Tomahawk
Hi Shai,
Unless you have a very, very poorly written interrupt handler this can't really happen. Even at the fastest baudrate possible with your clock rate you should be able to store a string away to a buffer successfully.
You have one byte time to process each byte before overrun occurs.
Perhaps you can post your ISR?
Are you correctly resetting the interrupt flag?
Regards David
Hi Peg,
I absolutely agree with you that somthing is wrong here but I do not succeeded to understand what .
My interrupt code is written in my old massages, please can you check it and see if there any problem.
To tell you the true I don't think that its related to my code, because the OR flag set to "1" already when I "call" the read interrupt routine and the OR flag is automatic set (if I not mistake).
It's like the MCU not react like I expect from it. I have read the datasheet and I do not understand why the MCU react like this.
Can you guide me in this situation ? maybe it somthing in the RS232 configuration that I done incorrect ?
Thanks,
Shai
Hi Shai,
OK, after my comments about the supplied code I was assuming you would have rewritten it.
How do you know OR is set? Its not checked there!
Unfortunately I can't afford the time to assist you any further at the moment and I am soon travelling.
Hopefully someone else can pick this up for you.
Regards David