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

pic24hj and interrupts

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



Joined: 15 Sep 2007
Posts: 3

View user's profile Send private message

pic24hj and interrupts
PostPosted: Sat Sep 15, 2007 2:16 pm     Reply with quote

I've been using the microchip compiler for pic24h projects and I saw that ccs had a version for the pic24h as well. Since I like ccs better I decided to try it out.

I've got two basic problems immediately. The .h files for the chips don't define the interrupt flag for tbe2 (they do define rda2) and in looking at the assignments for the flags I don't see how to define it myself. Does anyone know what the define should be?

Second basic problem is that I can't get interrupts working at all. I'm just trying to set up a basic timer (I have a program sending data out the uart port at the correct baud rate using the internal commands) and get it to interrupt. So far I haven't been able to get it to do so. Has anyone gotten the basic timer interrupt to work and if so could you tell me the secret?

I setup the timer then enable the timer interrupt. What else do I have to do.
_________________
Larry Weaver
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Sat Sep 15, 2007 5:29 pm     Reply with quote

Have you looked at http://www.ccsinfo.com/forum/viewtopic.php?t=31639&sid=80c4eb01db805bd3dfdb50d5e422a47a
may not give you the answer however some code that refers to comm do work.

some example of enable interrupts

enable_interrupts(INT_RDA);
enable_interrupts(INT_TBE);
enable_interrupts(INT_TIMER1);
enable_interrupts(INTR_GLOBAL);

I have not tried the intrrupst in the 24 series, I will be in due course.

Have you looked at the samples, review the help file and the pdf ref manual
http://www.ccsinfo.com/downloads/PCDReferenceManual.pdf
_________________
What has been learnt if you make the same mistake? Wink
lweaver



Joined: 15 Sep 2007
Posts: 3

View user's profile Send private message

PostPosted: Sat Sep 15, 2007 5:53 pm     Reply with quote

Actually it is getting wierder. I looked at the assembly code and it is actully enabling the wrong interrupt. There are also interrupt vector address problems. I have a reported several of these issues to support and am waiting to see what they say.
_________________
Larry Weaver
lweaver



Joined: 15 Sep 2007
Posts: 3

View user's profile Send private message

PostPosted: Sat Sep 15, 2007 6:48 pm     Reply with quote

Ok, after quite a bit of playing around there are several problems with the compiler output. The interrupt vector for timer1 is correct, but the ones for tbe, rda and rda2 are not. If you use the enable interrupt for timer1 the code that is put in the chip enables the interrupt for the wrong device

405: clear_interrupt(INT_TIMER1);
00E84 A96004 bclr.b 0x0004,#3
406: enable_interrupts(INT_TIMER1);
00E86 A86096 bset.b 0x0096,#3
407: bit_clear(IFS0,3);
00E88 A96084 bclr.b 0x0084,#3
408: bit_set(IEC0,3);
00E8A A86094 bset.b 0x0094,#3

The clear_interrupt and the enable_interrupt are from the compiler and as you can see they clobber bits in totally different registers than they should be messing with (the second two instrucitons are the correct ones). When I remove the bad code ones and use the correct code, the timer interrupt works perfectly (I also put the proper clear interrupt in the interrupt routine).
_________________
Larry Weaver
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