[PIC] Reentrancy of function

Status
Not open for further replies.

swapan

Full Member level 4
Joined
Feb 20, 2009
Messages
204
Helped
27
Reputation
54
Reaction score
24
Trophy points
1,298
Location
Kolkata
Visit site
Activity points
2,839
Hi guys,

While writing a code, I have used ‘ADC_Read( )’ function in main as well as in ISR. But the compiler returns the result ‘Reentrancy of function is not allowed’. Is there no way to get ADC result by calling ‘ADC_Read( )’ function in main as well as ISR?




swapam
 

No, you can't use ADC_Read() inside ISR. I guess you are using mikroC PRO Compiler. If you want to read adc when certain interrupt occurs then jsut set a flag in ISR and in while(1) loop check if this flag is set and if set then read adc and clear the flag.
 

Thanks milan.rajik. Yes I am using mikroC PRO Compiler. Actually I was trying to write a code for Home UPS. During battery charging I intended to check the charging current at a particular point of each half cycle of AC mains. If ADC sampling of charging current is taken at random, reading may differ to a great extent for an average value. Thus it will not be possible to maintain a constant charging current. Hence I thought to take sample immediately after zero cross pulse which is used as external interrupt, thus the value of sample for charging current will be more or less same. That's why I have put ADC_Read() function in ISR. Have you got the idea? Please suggest any way.

swapan
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…