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

interrupt routine wont work!

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



Joined: 20 Dec 2003
Posts: 14

View user's profile Send private message

interrupt routine wont work!
PostPosted: Wed Mar 03, 2004 10:28 am     Reply with quote

Hello All,

I am trying to toggle pin RD1 on a H->L external interrupt. Initially I set RD1 to high in main and then on an external interrupt from H->L, I set it permanently low.
I see that RD1 stays high on powerup and does not go low even afer a H-L interrupt on RB0. Here is the relevant code. Please explain why I see this unusual behavior. I use PIC16F874A and PCM compiler.

Thanks.
mach

***********************************************************
port declares;

#INT_EXT

intRB0()
{
#asm
BCF 0x3, 0x5 select Bank 0
BCF 0x8, 0x1 clear RD1 high
#endasm
}


main()

{

ENABLE_INTERRUPTS(INT_EXT);

ENABLE_INTERRUPTS(GLOBAL);

EXT_INT_EDGE(H_TO_L);

//port initialization

#asm
CLRF 0x03 // Bank0
CLRF 0x05 // Initialize PORTA by clearing output
CLRF 0x06 // Initialize PORTB by clearing output
CLRF 0x07 // Initialize PORTC by clearing output
CLRF 0x08 // Initialize PORTD by clearing output
CLRF 0x09 // Initialize PORTE by clearing output
// data latches
BSF 0x03, 5 // Select Bank1
MOVLW 0xFF // Value used to initialize data direction
MOVWF 0x85 // PORTA<7:0> = inputs
MOVLW 0xFF // Value used to initialize data direction
MOVWF 0x86 // PORTB<7:0> = inputs
MOVLW 0xBE // Value used to initialize data direction
MOVWF 0x87 // PORTC<7:0> = inputs
MOVLW 0xFD // Value used to initialize data direction
MOVWF 0x88 // PORTD<7:0> = inputs
MOVLW 0xFF // Value used to initialize data direction
MOVWF 0x89 // PORTE<7:0> = inputs

#endasm

output_high(PIN_D1);

while(true)
{
software SPI statements;
}

}

**********************************************************
tmach



Joined: 20 Dec 2003
Posts: 14

View user's profile Send private message

minor correction
PostPosted: Wed Mar 03, 2004 10:40 am     Reply with quote

Just to avoid confusion, I should say that in my ISR, two statements are commented

intRB0()
{
#asm
BCF 0x3, 0x5 //select Bank 0
BCF 0x8, 0x1 //clear RD1 high
#endasm
}
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Mar 03, 2004 11:04 am     Reply with quote

This is how I setup discrete IO. It is easier to read like this. I think you were settings the TRIS in the wrong bank.

Code:


#define Port_A_Mask 0b101111
#define Port_B_Mask 0b11111111
#define Port_C_Mask 0b10000110
#define Port_D_Mask 0b11111111
#define Port_E_Mask 0b00000000
#define Port_F_Mask 0b01111111
#define Port_G_Mask 0b00100
/***********************************************************
*    Initialize Discrete IO                                *
***********************************************************/
#inline
void Initialize_Discrete_IO(void)
{  #use fast_io (A)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (B)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (C)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (D)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (E)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (F)                                         // Do not set I/O tri-state status automaticly
   #use fast_io (G)                                         // Do not set I/O tri-state status automaticly
   SET_TRIS_A(Port_A_Mask);                                 // Set I/O tri-state status
   SET_TRIS_B(Port_B_Mask);                                 // Set I/O tri-state status
   SET_TRIS_C(Port_C_Mask);                                 // Set I/O tri-state status
   SET_TRIS_D(Port_D_Mask);                                 // Set I/O tri-state status
   SET_TRIS_E(Port_E_Mask);                                 // Set I/O tri-state status
   SET_TRIS_F(Port_F_Mask);                                 // Set I/O tri-state status
   SET_TRIS_G(Port_G_Mask);                                 // Set I/O tri-state status
   output_e(0);                                             // Force off status of outputs
   setup_spi(SPI_MASTER |SPI_H_TO_L | SPI_CLK_DIV_64 );
}
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