View previous topic :: View next topic |
Author |
Message |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
UART and Errors |
Posted: Fri Apr 30, 2010 2:56 am |
|
|
I am having a problem understanding the errors part of the #use RS232 function. I want to know if there was a problem during transmission so have set the timeout and errors but don't understand how to know if there was a timeout. If there was a problem I was to resend the data so need to know if there where any problems.
My code:
Code: | #use RS232(Uart1,Baud=9600,Timeout=10,Errors) |
I think I read somewhere that Errors would be set to 0 if there had been a timeout so I tried this but it gives me an error.
. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 30, 2010 1:35 pm |
|
|
This test program compiles OK with no errors, with vs. 4.107:
Code: |
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, TIMEOUT=500, ERRORS)
//=========================================
void main()
{
int8 c;
int8 result;
c = getc();
if(RS232_ERRORS == 0)
printf("Got Timeout Error \n\r");
while(1);
} |
|
|
|
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
Posted: Sat May 01, 2010 12:48 am |
|
|
cheers PCM
got it working now. Had it in an or statement and that was the problem. having never used errors I guessed that was the problem. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Sat May 01, 2010 2:33 pm |
|
|
Errors doesn't end errors they are still there that's why it's called errors instead of error-free. All errors does is allow the uart to continue since your are effectively considered to have handled the error. Now in reality there isn't much you can do with the error since there is no good way to recover the data. The value is that the error is detected and the uart kept alive so a sophisticated program could ask for a retransmission. The value in the variable error is mostly the value in the uart register that informs of the specific error. |
|
|
|