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

enable_interrupt issue (multiple source files)

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

enable_interrupt issue (multiple source files)
PostPosted: Thu Mar 31, 2011 3:41 pm     Reply with quote

Hi There,

I figured out how I can distribute my code into multiple source files yesterday but am experiencing some major issues with that today:
I wrote following test program to display my problem:
main.c
Code:

#include <18F87K22.h>
#device HIGH_INTS=TRUE, adc=16, ICD=TRUE
#FUSES NOWDT                      //No Watch Dog Timer
#FUSES WDT128                     //Watch Dog Timer uses 1:128
#FUSES HSM                        //Hi-Speed crystal oscillator
#FUSES NOBROWNOUT                 //No brownout reset
#FUSES NOPLLEN                    //No PLL enabled
#FUSES BBSIZ1K                    //1K words Boot Block size
#FUSES NOXINST                    //Extended set extension and Indexed
#define PC_RX PIN_C7
#define PC_TX PIN_C6
#define BAUDRATE 9600
#use delay(clock=10000000)
#use rs232(baud=BAUDRATE,parity=N,xmit=PC_TX,rcv=PC_RX,bits=8,stream=PC, ERRORS)
#bit RC1IE = getenv("bit:RC1IE")    // Get the receive interrupt enable bit from USART1
#include "interrupt.c"
#include "function.c"

void enableINT(void);

void main (void)
{
   enableINT();
   while (RC1IE);
   fprintf(PC,"EXIT!");
   
}

interrupt.c
Code:

 #int_rda2

  void RDA2_isr()
  {
     fputc(fgetc(PC),PC);
}

function.c
Code:

void enableINT(void)
{
   enable_interrupts (int_RDA);
   enable_interrupts(GLOBAL);
}


Now the problem is, that I want to enable the RDA interrupt from my function enableINT() in function.c but it doesn't work (it however doesn't leave the while loop in main())- it however works just fine with my timer interrupts - why is that, any clues?
Hints and suggestions are appreciated!
Thanks!

Oh, I'm using 4.119
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 3:50 pm     Reply with quote

Three things:

First, you don't have to start a new thread on the same topic.
You should add it on to your existing thread on multiple files.

2nd, you're changing the case of the CCS constants. You can only
get away with that because CCS, unlike most compilers, is not case
sensitive by default. It's a bad habit to get into, and it breaks up
speed reading of your code by other people.

3rd, you have #int_rda2 specified as your isr, but your #use rs232() pins
and your enable_interrupts(), and "RC1IE" all refer to UART1, which is
plain old INT_RDA (not rda2).
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 3:58 pm     Reply with quote

PCM programmer wrote:
Three things:

First, you don't have to start a new thread on the same topic.
You should add it on to your existing thread on multiple files.

2nd, you're changing the case of the CCS constants. You can only
get away with that because CCS, unlike most compilers, is not case
sensitive by default. It's a bad habit to get into, and it breaks up
speed reading of your code by other people.

3rd, you have #int_rda2 specified as your isr, but your #use rs232() pins
and your enable_interrupts(), and "RC1IE" all refer to UART1, which is
plain old INT_RDA (not rda2).


true

okay... yep...have to fix

yep, just saw this looking at it again and i actually am not able to recreate the issue i have in my main program in a little simple sample here so i guess it's gonna take me some time to figure it out...Confused

Thanks for pointing out these things! You are - as always - super helpful! Thanks for that!
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