Hi,help needed from Milan,Italy
I want to use the XGATE coprocessor in a 9S12X Freescale uC
I followed indications in AN3144 but i cant reach the interrupt routine
for XGATE in case oft PeriodicInterrupTimer0 interrupt,so i ask your help:
The interrupt is correctly managed if routed to the main CPU
If i try to route it to the XGATE the program goes to :
ISR(Cpu_Interrupt)
{
asm(BGND);
}
without passing through the default interrupt handler,
why?
I tried to resume the code.
From main i call SetupXGate()
static void SetupXGATE(void)
{
XGVBR= (unsigned int)(void*__far)(XGATE_MyVectorTable -
XGATE_VECTOR_OFFSET);
ROUTE_INTERRUPT(PIT_VEC, 0x81); /* RQST=1 and PRIO=1 */
XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */
}
i supposed PIT_VEC=0x7A:in AN3144 is used SCI0_VEC=0xD6;If this is from the
main CPU vectors table- > PIT_VEC=0x7A,right?
I put in the .cxgate file the XGATE vector table and the interrupts handlers:
#include <hidef.h>
#include "xgate.h"
#include "intrinsics_xgate.h"
//the following 3 rows are from Simple SCI.mc example
#pragma push
#pragma DATA_SEG XGATE_DATA
#pragma pop
//***************************default handler****************************
interrupt void ErrorHandler(int dataptr)
{
int chanNum= dataptr;
asm BRK;
}
//***************************my handler****************************
interrupt void PIT_Thread(int myint)
{
//toggle a pin ,check on oscilloscope
if(PORTB & 0x1)PORTB &=~0x1;
else PORTB |= 0x1;
}
//******* XGATE vector table*****************
/* assign the vector table in separate segment for dedicated placement in
linker parameter file */
#pragma CONST_SEG XGATE_VECTORS
const XGATE_TableEntry XGATE_MyVectorTable[] = {
// Channel # = Vector address / 2
/* channel 0..8 are not used, first used must match macro
XGATE_VECTOR_OFFSET in xgate.h */
{ErrorHandler, 0x09}, // Channel 09 - Reserved
{ErrorHandler, 0x0A}, // Channel 0A - Reserved
.....
.....
{ErrorHandler, 0x39}, // Channel 39 - XGATE Software Trigger 0
{ErrorHandler, 0x3A}, // Channel 3A - Periodic Interrupt Timer
{ErrorHandler, 0x3B}, // Channel 3B - Periodic Interrupt Timer
{ErrorHandler, 0x3C}, // Channel 3C - Periodic Interrupt Timer
{PIT_Thread, 0x3D}, // Channel 3D - Periodic Interrupt Timer //***
{ErrorHandler, 0x3E}, // Channel 3E - Reserved
{ErrorHandler, 0x3F}, // Channel 3F - Autonomous Periodical interrupt API
.....
.....
};
Thank you for your attention and any hint
please forgive not proper use of english language
Diego
Solved! Go to Solution.
Does the code in AN3144 using the sci work for you?
Also have a look at a newly created project with the wizard, when targeting the XGATE it calls to the XGATE with a software trigger.
wizard sample code:
#define ROUTE_INTERRUPT(vec_adr, cfdata) \ INT_CFADDR= (vec_adr) & 0xF0; \ INT_CFDATA_ARR[((vec_adr) & 0x0F) >> 1]= (cfdata)#define SOFTWARETRIGGER0_VEC 0x72 /* vector address= 2 * channel id */static void SetupXGATE(void) { /* initialize the XGATE vector block and set the XGVBR register to its start address */ XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET); /* switch software trigger 0 interrupt to XGATE */ ROUTE_INTERRUPT(SOFTWARETRIGGER0_VEC, 0x81); /* RQST=1 and PRIO=1 */ /* enable XGATE mode and interrupts */ XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */ /* force execution of software trigger 0 handler */ XGSWT= 0x0101;}
Daniel
Does the code in AN3144 using the sci work for you?
Also have a look at a newly created project with the wizard, when targeting the XGATE it calls to the XGATE with a software trigger.
wizard sample code:
#define ROUTE_INTERRUPT(vec_adr, cfdata) \ INT_CFADDR= (vec_adr) & 0xF0; \ INT_CFDATA_ARR[((vec_adr) & 0x0F) >> 1]= (cfdata)#define SOFTWARETRIGGER0_VEC 0x72 /* vector address= 2 * channel id */static void SetupXGATE(void) { /* initialize the XGATE vector block and set the XGVBR register to its start address */ XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET); /* switch software trigger 0 interrupt to XGATE */ ROUTE_INTERRUPT(SOFTWARETRIGGER0_VEC, 0x81); /* RQST=1 and PRIO=1 */ /* enable XGATE mode and interrupts */ XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */ /* force execution of software trigger 0 handler */ XGSWT= 0x0101;}
Daniel
Thank you Daniel
No i didn't tried with the Simple SCI example because i dont have the mcp,or at least i was not able to found it in the CW CD.
I just get some files in HTML format from the web
Tomorrow(0:05 AM now here) i'll try better using the wizard,as you suggest,by now i can't see where the error is ;my actual code, if compared
with the one generated by wizard seems to follow the same logic(right??),and i would be happy idf i could correct that difference that i can't see.
Thank you again
Diego