XAGTE CPU stops working after EnableInterrupts;

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

XAGTE CPU stops working after EnableInterrupts;

3,416 次查看
Peder
Contributor I
I'm using MC9S12XDT256, but can't get it to work with interrupts. I'm trying to use the CAN module and want the receiver interrupt to work with this function
 
Code:
#pragma CODE_SEG NON_BANKEDvoid interrupt CAN4RxISR(void) {    unsigned char length, index;    unsigned char rxdata[8];    length = (CAN4RXDLR & 0x0F); for (index=0; index<length; index++)       rxdata[index] = *(&CAN4RXDSR0 + index); /* Get received data */    CAN4RFLG = 0x01;   /* Clear RXF */}#pragma CODE_SEG DEFAULT

 I added the row VECTOR ADDRESS 0xFF92 CAN4RxISR in my .prm file (right address??). In main I added:
 
Code:
void main(){CanInit();while(!(CAN4CTL0&0x10));  /* Wait for Synchronization */   CAN4RFLG = 0xC3;          // Reset Receiver FlagsCAN4RIER = 0x01;          // Enable Receive Buffer Full InterruptEnableInterrupts;for(;;)
...}

 
After executing the "EnableInterrupts;" row the processor freaks out and no other code executes. What's wrong? I'm not using the XGATE functions nor have I written any code to disable it (do I have to)?
标签 (1)
0 项奖励
回复
5 回复数

1,682 次查看
Nabla69
Contributor V
Hello,
 
You need to make sure all other interrupt vectors are assigned to some code and vectors not left empty.
The probable scenario is you have another interrupt pending when you enable interrupt globablly and its vector is fetched.
If the vector fetched is not initialized, it causes troubles with the execution.
 
Also need to precise some language mistake.
XGATE CPU is not a term used. IT is either the CPU or the XGATE.
 
The XGATE works on event and is stopped otherwise. If you didn't give the XGATE any thread to execute it does not do anything.
 
Alvin.
0 项奖励
回复

1,682 次查看
Peder
Contributor I
Is there a way to see which vector is beeing fetched? Maybe I can disable those interrupts that are running.
 
Right now I have made a _dummyISR function and added all interrupt vectors in my .prm file like this:
 
Code:
#pragma CODE_SEG NON_BANKED#pragma TRAP_PROCvoid _dummyISR( void ){    for(;;)   {;}                                 }#pragma CODE_SEG DEFAULT

 
Code:
VECTOR  0   _Startup   /* reset vector: this is the default entry point for a C/C++ application. */VECTOR 1  _dummyISR  // 0xFFFC  Clock Monitor fail resetVECTOR 2  _dummyISR  // 0xFFFA  COP failure resetVECTOR 3  _dummyISR  // 0xFFF8  Illegal opcode...

 
Still no code after EnableInterrupts; executes. When I stop the program I'm in the _dummyISR function and not in my main for-loop. :smileymad:
0 项奖励
回复

1,682 次查看
Lundin
Senior Contributor IV
Write a separate ISR for every vector? So you can see what is causing the interrupt.
0 项奖励
回复

1,682 次查看
Nabla69
Contributor V
Hi,
 
I like this idea as you can even display on LED the vector number. I use it :smileyhappy:
 
Otherwise, if you don't want to update the code, put a breakpoint inside the ISR
and look which interrupt flag is set. :smileysad:That could be a little fastidious though.
 
I'd advise to use a different ISR code for interrupt vectors linked to a Reset like Clock Minitor, COP and so on. This way you know straight away that somthing is bad !:smileywink:
 
Alvin.
0 项奖励
回复

1,682 次查看
Peder
Contributor I
The solution is found. One extra friday beer for me :smileyvery-happy:
 
I did separate interrupt functions for a couple of interrupts and found that the IRQ interrupt was on by default. IRQCR = 0x00; did the thing! IRQCR was 0x40 at start and trigged on my grounded IRQ pin all the time after EnableInterrupts; was executed.
 
Better head back to my CAN-repeater project. Thanks for all help!
 
0 项奖励
回复