CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Understanding serial behavior

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gerrit
Guest







Understanding serial behavior
PostPosted: Tue Apr 08, 2003 6:39 am     Reply with quote

Hello all,

Can someone explain to me how it works?

I use two interupts 1 serial 1 timer.
The timer has high priorety
The timer interupt can spend more time than the
length of a serial byte, but not more the 3 bytes.

What happens if timer and serial interupt happen at the same
time, and during timer interupt routine an other byte is received?

1 after timer routine I get 2 times an interupt for reading a serial byte.

2 after timer routine I get 1 time an interupt for reading a serial byte and no interupt until the next byte is received.



I know that it is not wise to spend that mutch time in an interupt, but that is not what I want to know.




Regards,


Gerrit
___________________________
This message was ported from CCS's old forum
Original Post ID: 13492
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Understanding serial behavior
PostPosted: Tue Apr 08, 2003 8:41 am     Reply with quote

<font face="Courier New" size=-1>:=Hello all,
:=
:=Can someone explain to me how it works?
:=
:=I use two interupts 1 serial 1 timer.
:=The timer has high priorety
:=The timer interupt can spend more time than the
:=length of a serial byte, but not more the 3 bytes.
:=
:=What happens if timer and serial interupt happen at the same
:=time, and during timer interupt routine an other byte is received?
:=
:=1 after timer routine I get 2 times an interupt for reading a serial byte.
:=
:=2 after timer routine I get 1 time an interupt for reading a serial byte and no interupt until the next byte is received.
:=
:=
:=
:=I know that it is not wise to spend that mutch time in an interupt, but that is not what I want to know.
:=
:=
:=
:=
:=Regards,
:=
:=
:=Gerrit


You can increase the crystal speed, lower the baud rate or reduce the timer duration. Otherwise you will miss incomming bytes. The time it takes to handel a timer interupt and two serial interupts must be less than 2 byte periods.


Assume this is timer interupts over time
-T---------------------------------------T--

Assume this is serial interupts over time
S--------S--------S--------S--------S--------

Assume this is the duration of a timer interupt
TI----------

Assume this is the duration of a serial interupt
SI-

-T---------------------------------------T--
S--------S--------S--------S--------S--------
SI-TI----------SI-SI-

The second serial byte must be moved from the serial buffer before the third byte arrives.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13495
R.J.Hamlett
Guest







Re: Understanding serial behavior
PostPosted: Tue Apr 08, 2003 10:45 am     Reply with quote

:=Hello all,
:=
:=Can someone explain to me how it works?
:=
:=I use two interupts 1 serial 1 timer.
:=The timer has high priorety
:=The timer interupt can spend more time than the
:=length of a serial byte, but not more the 3 bytes.
:=
:=What happens if timer and serial interupt happen at the same
:=time, and during timer interupt routine an other byte is received?
:=
:=1 after timer routine I get 2 times an interupt for reading a serial byte.
:=
:=2 after timer routine I get 1 time an interupt for reading a serial byte and no interupt until the next byte is received.
:=
:=
:=
:=I know that it is not wise to spend that mutch time in an interupt, but that is not what I want to know.
:=
You will have problems.
Firstly, it is the time in the timer interrupt, plus the time taken to handle the serial interrupt (and the latencies involved both in the hardware, and in saving/restoring the registers), that all have to be added together to get the 'worst case' scenario.
The second problem is that there are not three characters of buffer time available. Consider the situation where the receive register finishes a character one clock after the timer interrupt has occured...
You will lose data, and get the overrun error bit set.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13503
Gerrit Faas
Guest







Re: Understanding serial behavior
PostPosted: Tue Apr 08, 2003 10:49 am     Reply with quote

Hi Neutone,

I understand that this example is not correct, but I have a problem with 3th party controler, and I want to isolate the problem.

What happens if the next situation was real:

the serial interupt only read 1 byte:

************ = time in the timer interupt

:=-T************----T--
:=--S--------S--------S--------S--------S--------

:=-TI----------SISI-TI---- is this the behaviour or

:=-TI----------SI---TI----


Regards,



Gerrit


:=<font face="Courier New" size=-1>:=Hello all,
:=:=
:=:=Can someone explain to me how it works?
:=:=
:=:=I use two interupts 1 serial 1 timer.
:=:=The timer has high priorety
:=:=The timer interupt can spend more time than the
:=:=length of a serial byte, but not more the 3 bytes.
:=:=
:=:=What happens if timer and serial interupt happen at the same
:=:=time, and during timer interupt routine an other byte is received?
:=:=
:=:=1 after timer routine I get 2 times an interupt for reading a serial byte.
:=:=
:=:=2 after timer routine I get 1 time an interupt for reading a serial byte and no interupt until the next byte is received.
:=:=
:=:=
:=:=
:=:=I know that it is not wise to spend that mutch time in an interupt, but that is not what I want to know.
:=:=
:=:=
:=:=
:=:=
:=:=Regards,
:=:=
:=:=
:=:=Gerrit
:=
:=
:=You can increase the crystal speed, lower the baud rate or reduce the timer duration. Otherwise you will miss incomming bytes. The time it takes to handel a timer interupt and two serial interupts must be less than 2 byte periods.
:=
:=
:=Assume this is timer interupts over time
:=-T---------------------------------------T--
:=
:=Assume this is serial interupts over time
:=S--------S--------S--------S--------S--------
:=
:=Assume this is the duration of a timer interupt
:=TI----------
:=
:=Assume this is the duration of a serial interupt
:=SI-
:=
:=-T---------------------------------------T--
:=S--------S--------S--------S--------S--------
:=SI-TI----------SI-SI-
:=
:=The second serial byte must be moved from the serial buffer before the third byte arrives.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13504
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group