View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Mon Nov 08, 2004 3:19 pm |
|
|
Twom thing important to understand from your posting.
one is Never put those huge delays in there
another is There is no #int_rda with a software USART
thank you guys |
|
|
Twitie
Joined: 08 Nov 2004 Posts: 11
|
|
Posted: Mon Nov 08, 2004 5:34 pm |
|
|
Quote: |
5. Never put those huge delays in there. Better to set a flag and handle in main.
6. Better use "ERRORS" in the #use RS232 if using the hardware uart.
|
Sorry guys for interrupt~ I have some doubt regarding your postings. Hope that anyone of you can answer my doubt.
Q1> Why we shouldn't use those huge delays in the program? 300ms is considered huge?
Q2> If so, what is the better way to implement delay? (coz I am using delay in my program too... just like young)
Q3> What is the usage of "ERRORS" in #use RS232?
Thank you very much! Looking forward for your replies~ |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 08, 2004 6:14 pm |
|
|
Quote: | Q1> Why we shouldn't use those huge delays in the program? 300ms is considered huge?
|
Okay for a program but you shouldn't do them in an interrupt.
Quote: | ERRORS
Used to cause the compiler to keep receive errors in the variable RS232_ERRORS and to reset errors when they occur.
|
He is not doing any error checking. A buffer overrun will cause the receive to stop working unless the error is handled. The ERROR parameter will do this for him. |
|
|
Twitie
Joined: 08 Nov 2004 Posts: 11
|
|
Posted: Mon Nov 08, 2004 7:16 pm |
|
|
Thx Mark~ ^^
Quote: | Okay for a program but you shouldn't do them in an interrupt.
|
One more question. What should I do if I need to implement delay in intterupt?
Thx. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 08, 2004 8:21 pm |
|
|
Rewrite it so you don't
Usually you can set a flag and then handle the interrupt in the main loop. Ints are supposed to be as short and fast as possible. |
|
|
Twitie
Joined: 08 Nov 2004 Posts: 11
|
|
Posted: Mon Nov 08, 2004 8:27 pm |
|
|
That's mean I use the interrupt subroutine only to set the flag and the all the work for interrupt will be done in main()...
Thx Mark, I think I get your point~~ |
|
|
|