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

RDA Interrupt support on PIC24FJ32GB002?

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



Joined: 31 Mar 2013
Posts: 3

View user's profile Send private message

RDA Interrupt support on PIC24FJ32GB002?
PostPosted: Sun Mar 31, 2013 7:46 pm     Reply with quote

Hi All,
Complete newbie here. I can't get an interrupt to fire on my PIC24FJ32GB002. I heard that there might not be support for some "Exotic" PIC24s, is this the case or am I doing something wrong?

The RDA isn't firing but I can get an external interrupt to fire.

Compiler Ver: 4.132

Here's my test program:
Code:

#FUSES PR
#FUSES FRC                  //Internal Fast RC oscillator with PLL
//#FUSES EXT0   //External interrupt

//#FUSES PLLDIV8                  //Divide By 8(32MHz oscillator input)
//#FUSES SOSC_IO                  //SOSC pins have digital I/O functions
#use delay(clock=8M)
#use rs232(baud=9600,xmit=pin_a0,rcv=pin_a2,errors)
#use fixed_IO(B_outputs = PIN_B0,PIN_B0,PIN_B1,PIN_B1,PIN_B2,PIN_B2)

#include <ZombieLink_16_Bit_ch.h>
//#include <LCD.C>

#define HB PIN_B0
int1 interrupt_flag = 0;
#int_rda
void serial_isr()
{
   interrupt_flag = 1;
 
}

#int_EXT0
void ext_isr()
{
interrupt_flag = 1;
}

/*#int_USB
void  USB_isr(void)
{

}
*/


//#use rs232(UART1,baud=9600,parity=N,bits=8)

void main()
{
//          enable_interrupts(INT_USB);
          enable_interrupts(int_rda);
          enable_interrupts(int_EXT0);
ext_int_edge( H_TO_L );   

   while(True)
   {
      delay_ms(1000);
      output_toggle(HB);
     
     printf("hello world");

      if (interrupt_flag == 1)
      {
         interrupt_flag = 0;
         printf("Interrupt Fired!");
      }
 
     
   // TODO: USER CODE!!
   }
}
jeremiah



Joined: 20 Jul 2010
Posts: 1321

View user's profile Send private message

PostPosted: Sun Mar 31, 2013 10:39 pm     Reply with quote

You have some stuff wrong with the program. You should clean it up a bit:

1. Get rid of all the USB code, even the stuff commented out. Makes it hard to even try to debug when we have to filter out unnecessary stuff.

2. Take out the other commented out code/unused code

3. Not enabling the global interrupt (INTR_GLOBAL), which should be done

4. I believe you should be reading the incoming byte in the RDA isr. I don't remember offhand for the PIC24, but I think if you don't the interrupt will continually fire.

5. Don't use fixed_io for now. Keep it simple and let the compiler handle stuff like that until you get the basics figured out.

6. I'm not sure PR and FRC are compatible fuses. You should look more closely at those.

7. Possibly start with the example given in the examples folder in the PICC directory structure (ex_sisr.c).

8. You don't have an include line for the chip.h file. This can be a real big no no.

9. RA2 is not available for a hardware uart, you need all remappable pins. That means no interrupt.

In terms of the chip family, I have primarily used the pic24FJXXGAXXX family and have been able to get the ex_sisr.c program to run on that. I have only dabbled with the GB version, so I don't have more experience with it.
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Mon Apr 01, 2013 12:22 am     Reply with quote

PIN_A2 is not a RP pin, so can't assign RD to it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Mon Apr 01, 2013 1:44 am     Reply with quote

and, if it was, you'd need to use #pin_select to do so.

Best Wishes
justsomeguy1983



Joined: 31 Mar 2013
Posts: 3

View user's profile Send private message

PostPosted: Mon Apr 01, 2013 11:27 am     Reply with quote

Many thanks for all your tips!

I'll go through, try them all and report back!

Like I said I'm pretty new here. Can you guys think of any books I could use to get up to speed with the basics?
temtronic



Joined: 01 Jul 2010
Posts: 9161
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 01, 2013 11:39 am     Reply with quote

hmm...if that PIC has 2 serial ports, you have 2 ISRs as well! Be sure to code accordingly.

The 'school of hard knocks' can be painful but there's a lot of good info on this forum.

I get a basic 'LED blinking at the right speed' program running,clone it,then upgrade the clone.test,if OK, clone that program,then upgrade it, test, ad nauseum.
Worst thing is to take a known good program , make 3 changes and spend 4 dayze wondering why it don't work.

I have 40-50-60 'versions' to most of my code.Yes, excessive, but I can go back to the 'yup,worked here' anytime.

I also have separate 'header' files for pin use and fuses.In the programx.fuz file a clean list of all fuses( 1 per line) used. In the programx.pnz, every I/O pin is defined(if not used, pin_a1_nu).This way the 'main' prgram isn't cluttered with 30 fuses and 28 pin defines,it's easier for me to see what everything is.


hth
jay
justsomeguy1983



Joined: 31 Mar 2013
Posts: 3

View user's profile Send private message

PostPosted: Mon Apr 01, 2013 4:38 pm     Reply with quote

Hey Guys, The pin select did the trick!
A0 and A2 worked too.

I really appreciate the tips!
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