View previous topic :: View next topic |
Author |
Message |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
input (GIN1) during timer INT call |
Posted: Fri Aug 07, 2015 3:09 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Fri Aug 07, 2015 3:27 am |
|
|
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.... |
|
![](templates/subSilver/images/spacer.gif) |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Fri Aug 07, 2015 3:32 am |
|
|
Code: | #INT_TIMER1
void timer1_isr(VOID)
{
in[0] = input (GIN1) ;
} |
_________________ Help "d" others and then you shell receive some help from "d" others. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Fri Aug 07, 2015 4:59 am |
|
|
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?. |
|
![](templates/subSilver/images/spacer.gif) |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Fri Aug 07, 2015 9:25 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Fri Aug 07, 2015 12:12 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Sat Aug 08, 2015 2:42 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|