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

is input() function is reentrant ?

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



Joined: 16 Jan 2008
Posts: 61

View user's profile Send private message

is input() function is reentrant ?
PostPosted: Tue Dec 23, 2008 1:12 pm     Reply with quote

Hi,

I am using pic18f2520 and I am using CCS IDE 4.083. I want to use input() function to read port within an isr routine. But when I am using it first time it reads, but while running again it doesn't read and is stuck in a loop.

Does input() function have the same problem as delay_ms() or not?

thanks
nehal
_________________
nehal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 23, 2008 1:30 pm     Reply with quote

Make a test program. Look at the .LST file. The ASM code will tell you
what is happening.

Notice that the compiler creates a separate instance of the input()
function each time it is called. Also notice that there is no loop in
the code. It can't lock-up.
Quote:

.................... #INT_EXT
.................... void ext_isr(void)
.................... {
.................... char c;
....................
.................... c = input(PIN_B0);
009E: BSF F93.0 // Set TRISB.0 = input pin
00A0: CLRF 1A
00A2: BTFSC F81.0 // Read pin B0 and test it.
00A4: INCF 1A,F
....................
.................... }
....................
.................... //=================================
00A6: BCF FF2.1
00A8: GOTO 0058
.................... void main()
.................... {
00AC: CLRF FF8
00AE: BCF FD0.7
00B0: BSF 08.7
00B2: CLRF FEA
00B4: CLRF FE9
00B6: BSF FB8.3
00B8: MOVLW 08
00BA: MOVWF FAF
00BC: MOVLW 02
00BE: MOVWF FB0
00C0: MOVLW A6
00C2: MOVWF FAC
00C4: MOVLW 90
00C6: MOVWF FAB
00C8: MOVF FC1,W
00CA: ANDLW C0
00CC: IORLW 0F
00CE: MOVWF FC1
00D0: MOVLW 07
00D2: MOVWF FB4
00D4: CLRF 18
.................... char n;
....................
.................... n = input(PIN_B0);
00D6: BSF F93.0 // Set TRISB.0 = input pin
00D8: CLRF 19
00DA: BTFSC F81.0 // Read pin B0 and test it.
00DC: INCF 19,F
....................
....................
.................... while(1);
00DE: BRA 00DE


Here is the test program. It was compiled with vs. 4.083.
Code:
#include <18F2520.H>
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP   
#use delay(clock=20000000)                           
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#INT_EXT
void ext_isr(void)
{
char c;

c = input(PIN_B0);

}

//=================================
void main()
{
char n;

n = input(PIN_B0);


while(1);
}                             

If you still have a problem, then post a very short test program that
demonstrates the problem.
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