View previous topic :: View next topic |
Author |
Message |
lweaver
Joined: 15 Sep 2007 Posts: 3
|
pic24hj and interrupts |
Posted: Sat Sep 15, 2007 2:16 pm |
|
|
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
|
|
|
lweaver
Joined: 15 Sep 2007 Posts: 3
|
|
Posted: Sat Sep 15, 2007 5:53 pm |
|
|
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
|
|
Posted: Sat Sep 15, 2007 6:48 pm |
|
|
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 |
|
|
|