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 support@ccsinfo.com

interrupts+re-entracy

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



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

interrupts+re-entracy
PostPosted: Tue Mar 09, 2004 4:13 pm     Reply with quote

I am trying to call a function called display from within an ISR()
and from main().

I have been told that this causes interrupts to be disabled (re-entracy)

I have tried to make 2 copies of the display function but with different
names.

I still have had no luck, does anyone know how to cure this, possible showing by an example???

Hope someone can help!!!
_________________
Best Regards
Ttelmah
Guest







Re: interrupts+re-entracy
PostPosted: Wed Mar 10, 2004 3:55 am     Reply with quote

asjad wrote:
I am trying to call a function called display from within an ISR()
and from main().

I have been told that this causes interrupts to be disabled (re-entracy)

I have tried to make 2 copies of the display function but with different
names.

I still have had no luck, does anyone know how to cure this, possible showing by an example???

Hope someone can help!!!

You have two seperate problems.
The first is re-entrancy as you describe. But the second, is _hardware re-entrancy_. The LCD 'write' routine, expects to start with the signal lines in an 'idle' state, and proceed through a complete pattern without this being broken. If the interrupt protection is bypassed by having two routines, when the 'interrupt driven' one occurs while the LCD is allready being talked to in the external version, the result will be problems with the data pattern sent to the LCD...
There are two solutions, depending on the nature of your code. The first is to disable the interrupts in the version called outside the interrupt routine, but since the 'selection' of the characters from the strings will be outside this routine, this still allows the interrupt driven version to write to the display in the moments between. This will give very similar results to the default protection.
The second is to only write to the display in an interrupt. Consider using a timer interrupt at (say) 1/100th second intervals to write to the display. Since the slowest display commands typically take less than 10mSec, you can simply check a 'lcd buffer', to see if any characters are waiting, and if anything is, send just one character to the display. The actual write to the buffer will be so fast, that disabling interrupts for the time involved will be acceptable.
You should also consider the 'implications' of having writes coming from two sources. It'd really be better to set a flag in the interrupt, and have external code generate the text. Otherwise (for instance), if an external routine is generating a message 'Hello World' to the display, the interrupt code, can be called at any time, and could result in it's message appearing 'between the characters' of the message, as (for instance):
"HelINT messageo World".
This is why in general having a single 'display dispatcher', is a much better/safer way of coding.

Best Wishes
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