Ruth Hendrix

PART 2: DEMO9S12XDT512 Interrupt Questions

Discussion created by Ruth Hendrix Employee on Jan 26, 2006
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
Posted: Wed Aug 24, 2005 4:16 pm    

I solved the problem by using the following instructions.

  //INT_XGPRIO = 0x01;
  //INT_CFADDR = Vportp & 0xF0; //Set PortP for XGate
  //INT_CFDATA7 = 0x81;

That's the correct approach


One last question: How can I delete an Interrupt Flag from the Xgate module:

interrupt void _testPortP(void)
  asm NOP;
  //asm BRK;
  PIFP_PIFP0 = 1;       //clear interrupt flag PortP 0

this example ISR deletes the interrupt flag (PortP0) if serviced by the HCS12 core.
But in the Xgate module the corresponding adress of the PIFP register (PortP interrupt flag) doesn't work Sad.
Is there a header file or documentation about how to delete interrupt flags serviced by the Xgate?

Your code will be identical on the CPU and XGATE: that is the great joy of working in C with the XGATE - moving ISRs is very easy.
The address is actually the same for the CPU and for the XGATE since the registers are at the same location in each memory map, but even if it was not the CodeWarrior tools would automatically calculate the correct value.
I'm not sure if you are saying that the compilation fails or that the XGATE sets the wrong address. For the compile to work the XGATE source code must include the register header file. Also make sure your ISR is at the correct place in the XGATE vector table and is in the .cxgate file. (If it is in a .c file it will be compiled by the CPU compiler and the binary will be all wrong).
If the XGATE is not accessing the port to clear the flag then I would recommend you go to the debugger and trace what's happening.
To have a breakpoint on the demo board you must allow the CPU to load the XGATE code into RAM before you set the breakpoint.
You can do this by stepping into the the main routine since CW now loads the RAM in the startup file (with the initialisation).
Let us know how it goes.
Posted: Fri Aug 26, 2005 8:25 am    
thank you very much for your help! The interrupt jumps to the ISR. That works without any problem. But I still have the problem with deleting the interrupt flag. I tried it his way:
interrupt void _testPortP(void) //ISR in xgate.cxgate for PortP {   asm NOP;  XGIF4 |= XGIF4_XGIF_39_MASK; //write 1 interrupt to                                                   //PortP  (delete flag )    asm BRK; }

XGIF4 is the register where the corresponding interrupt flag in the XGate is deleted.
Following error ocurrs: write to RAM
May I work with semaphores???
Posted: Fri Aug 26, 2005 11:56 am    
XGATE does not clear the flag in the XGIF registers. These flags are only for the CPU and are used when XGATE sends an interrupt on to the CPU so if you are handing the interrupt onto the CPU then you need to do this at the CPU ISR. See the figure 9-1 in the manual for the structure.
The interrupt you have to clear is the PORTP interrupt flag itself as you showed in your previous code segment. If you clear this then XGATE will not interrupt again until the PORTP gets another trigger.
If you can trace through the ISR on XGATE then you should be able to check the value of the PORTP interrupt before you leave the ISR. Check that XGATE is writing to the port correctly and that the flag is being cleared and that should give you an idea if the code is ok. Maybe PORTP is getting lots of interrupts?