Hallo,
I've been playing with the HCS12SXE XGATEv3 for a while now.
Currently, I'm facing this odd issue, where the XGATE code seems to run fine: I've set up a GPIO pin toggle to check and see if the XGATE ISR is entered and executed correctly, and on the scope I see the GPIO pin toggling fine.
However, if I place a breakpoint at any part of the XGATE ISR, the XGATE raises an access violation interrupt request (non-maskable) to the HCS12XE core and halts code execution.
The original codebase uses Processor Expert. XGATE capabilities are now being added in.
Any ideas, on what could be possibly happening? Everything else checks out - XGATE vector table is correctly set, memory sections and code/data is aligned correctly on even boundaries.
Thanks in advance.
Hello Fahnder,
The trace simply lists a sequence of XGATE PC values. It begins with FC20'X, which is the "RTS" instruction of the previous iteration of the ISR. That's where you must have started the trace and it ends with FC1A'L (LDB R2,(R0,#8)). If the software error occurs at this point, then R1 should be 0xFC26, R2 should be "pData->counter" , at least one bit of the CCR should be set, and the PC should point to FC1A'L. I don't understand why you don't see this when you enter debug mode. Could that be a display issue of the IDE?
Let's assume the error occurs during the execution of the ISR and not during the vector fetch. There are 3 causes for a XGATE software error:
Can you verify, that the XGATE code space is still intact when the software error occurs.
Morning HSW,
I had to drop this for a while and figure out a workaround, but looks like I might have some time to look into this again.
Since then, I have written ISRs for handling SCI and SPI interrupts, and everything works perfectly in the project - but I still lack being able to set breakpoints in the XGATE ISRs.
Also, I verified the XGATE code space - it is not being overwritten by the CPU.
Hello Fahnder,
to understand what is going on with those breakpoints it might help to look at the configuration of the DBG module. Can you dump the DBG's register space (0x0020 to 0x0027) while you're executing your program (before you run into the breakpoint)? Maybe we'll find a hint there.
Hello Fahnder,
Your vector map and ISR seem to be set up correctly. When you took the screenshot after entering debug mode, while still in error state (Dropbox - Screenshot 2014-05-16 14.00.52.png), are you sure the IDE was showing the correct register content? Is it possible, that XGPC as well as XGR1-XGR7 just had not been refreshed after you set XGDBG?
HSW,
This is the sequence of steps I followed just now:
Hello Fahnder,
What happens when you start the SWT0 thread manually in debug mode?
After which step do you see the software error?
Morning HSW,
I did the following sequence of events:
Then I let the code 'free run' and immediately saw the XGATE software error triggered (i.e. code has halted execution, and was trapped at the breakpoint in "Cpu_ivVxsei").
To reiterate, this only appears to happen when a breakpoint is placed in the XGATE SWT0 ISR.
What else could I try?
I set the trigger module to trace the XGATE only, in Pure PC mode.
Just edited my previous reply, here's what I think is a "better" screenshot: https://www.dropbox.com/s/n50hjasqw48it9i/Screenshot%202014-05-20%2012.44.47.png
I can't quite understand the data yet ...
Hello Fahnder,
A XGATE SWT0 interrupt request has been captured by the XGATE (XGCHID=0x39), but no interrupt vector has been fetched (XGPC=0x0000, XGR1=0x0000). So you should have a look at the vector table. Since XGVBR is set to 0x07DC, the interrupt vector should be at 0x07DC+4*0x39=0x8C0 (or 0x7808C0 global). What do you see at this address?
Morning HSW,
I think you're onto something here, but I don't quite understand what's going on.
Name Addr hSize dSize Ref Section RLIB
XGATE_VectorTable E08800 1C4 452 1 XGATE_VECTORS
#define XGATE_VECTOR_OFFSET 9 | /* the first elements are unused and need not to be allocated (to save space) */ |
XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);
What am I doing wrong?
Hello Fahnder,
You'll need to be careful not to mix up the 3 memory maps of the S12XE family. These are:
Your program maps the XGATE's vector table to the start of the flash space at address 78_0800'G, E0_8800'L, and 0800'X. The XGVBR register is set to 07DC'X (= 0800'x - 9*4) because the first 9 vectors are never used.
The XGATE SWT0 vector is located at address 78_08C0'G, E0_88C0'L, and 08C0'X. Your screenshot shows that it contains the address FBF6'X. This translates to 0F_FBF6'G or 00_3BF6'L. This points into the RAM space. Do you have any valid code in there?
HSW,
You're right, I got confused between the three different types of memory maps.
As you said, the XGATE SWT0 vector is located at address 78_08C0'G, E0_88C0'L, and 08C0'X. The screenshot in the previous reply shows it contains the address FBF6'X.
However, this (FBF6'X) translates to 7BF6'L or FFBF6'G, if I am not mistaken.
I have my XGATE software trigger handler located at 7BF6'L: Dropbox - Screenshot 2014-05-19 11.09.51.png
Does this sound correct?
HSW,
I used the address mapping utility "hcs12xadrmap.exe" located in "C:\Program Files (x86)\Freescale\CWS12v5.1\Prog\". The utility shows me that the global address corresponding to FBF6'X should be 7BF6'L.
Dropbox - Screenshot 2014-05-19 13.52.47.png
Am I using it incorrectly?
Hello Fahnder,
I forgot about this mapping option. If you set the ROMHM and RAMHM bit in the MMCCTL1 register (0013'L), the RAM is mapped to the address range 2000'L - 7FFF'L. What is the content of the MMCCTL1 register in your application?
Fahnder,
In this case, XGATE Software error has occurred and the CPU is executing the non-maskable interrupt, as it is supposed to. What you"ll need to do next is to enter debug mode by writing 0x2020 to the XGMCTL register. Then you are able to read the RISC core's registers.
If you post a dump of the XGATE's register space and of the memory section which the PC points to, I'll help find the cause of the software error.
HSW,
Here's the information:
- XGATE register space:
Dropbox - Screenshot 2014-05-16 14.00.52.png
The XGATE PC points to 0x0000 (it seems to stay there when the XGATE is inactive, but maybe this is not correct behaviour).
Is there a better way for me to post the memory dumps?
Hello Fahnder,
The access error interrupt is triggered by the MPU, you shouldn't see it if the MPU was disabled. The MPU captures the address of the faulty access in the MPUASTAT register. Does this give you a hint for the cause of the problem?
The details of application note AN3555 only apply to the XGATEV2. The listed causes of a XGATE software error are the same for the XGATEV3, but the "observable conditions" are different.
But if I understood you correctly, you don't see a XGATE software error at the moment, right? The XGATE stops at a breakpoint and enters debug mode, while the CPU handles an non-maskable access error interrupt for an unknown reason.
One more thing you could check for is the stack. Is the stack pointer set to the correct RAM location?