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

input (GIN1) during timer INT call

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



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

input (GIN1) during timer INT call
PostPosted: Fri Aug 07, 2015 3:09 am     Reply with quote

Hi Guys,
Is it possible to read input state during a timer int in such way that I don't get "Interrupts disabled during call to prevent re-entrancy" warning?

In short I want to check input state every 50ms unconditionally.
If I do it in main loop then the timing is affected by processors load.

thnx 4 helping.
_________________
Help "d" others and then you shell receive some help from "d" others.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 3:27 am     Reply with quote

You need to show us what you are doing.

You can read a pin without interrupts being disabled easily. It sounds as if you are in fact calling your own routine to do this. If so, then interrupts will be disabled, and _have_ to be.

So if (for instance) you had to read a device by lowering a CS line, then reading an input pin and then raising the line, and called this in both the main and the interrupt. If you had just dropped the CS, and then the interrupt was called, the interrupt would drop the CS a second time (wouldn't matter), then read the device, and then raise the CS. So you'd arrive back at the read in the main code, with the line high.....

It's all down to what is being done. A simple read, no problem. But anything involving sequencing lines like this, if used both inside and outside the interrupt routines, then interrupts _must_ be disabled, or it isn't going to work....
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 3:32 am     Reply with quote

Code:
#INT_TIMER1
void timer1_isr(VOID)                                                   

     in[0] = input (GIN1) ;
}

_________________
Help "d" others and then you shell receive some help from "d" others.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 4:59 am     Reply with quote

Assuming GIN1, is #defined as a pin number, this won't disable interrupts.

Are you _sure_ this is what is giving the warning?.
Just test with:
Code:

#INT_TIMER1
void timer1_isr(VOID)
{
in[0] = 0;
}


Do you still get the warning?.

Compiler version?.
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 9:25 am     Reply with quote

It occurs when GIN1 is a variable. CCS calls a sub to resolve which pin you are addressing and will thus disable ints if it is used in an interrupt and main.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 07, 2015 12:12 pm     Reply with quote

Yes.
A person who doesn't keep to the old C standard of reserving ALL CAPITALS for defined values.

As a comment though, assuming a low number of pins involved it'll actually be smaller and faster to just test the value and select the pin.
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Sat Aug 08, 2015 2:42 am     Reply with quote

Code:
   // INPUT 8 -----------------------------------------------------------------
   if (instate[7] != input (GIN8))
   {
      inputdebouncing8 = 0;
      in8_active = 1;
      instate[7] = input (GIN8); // copy state to buffer
      recheck_input8 = 0;
   }     


Thnx Guys, you right I had VAR there.
_________________
Help "d" others and then you shell receive some help from "d" others.
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