BugMan up above had problems changing the MQX_ROM_VECTORS define. If you are using the m52259demo board, add the following line to the board-specific MQX settings in Freescale MQX 3.4\config\m52259demo\user_config.h:
#define MQX_ROM_VECTORS 0
Here's the part I messed up, open Freescale MQX 3.4\config\m52259demo\build_libs.mcp. Build this project which will update all of the sub-libraries.
Here is the simplest program that I can think of to create a kernel isr and start measuring some latencies. Create a blank hello world MQX project.
Here is the irq function:
extern void external_isr(pointer);
__declspec(interrupt:0) void external_isr(pointer testVal)
{
/* Set the bit */
PORTTC |= 0x08;
EPFR = 0x02;
}
add the following to the main task:
unsigned short temp;
int counter;
int outCnt;
unsigned char tmpU8;
#define PIT_INTRPT_FLAG 0x0004
/* Set up the PIT0 timer to provide 1 ms pulse */
PMR0 = 0x270f;
PCSR0 = 0x0217;
DDRTC = 0x0f;
PORTTC = 0x00;
counter = 0;
outCnt = 0;
/* Set up the Eport bit 1 to generate an interrupt on falling edge */
EPPAR = 0x0008;
EPIER = 0x02;
/* Install the kernel ISR */
_int_install_kernel_isr(MCF5225_INT_EPORT0_EPF1, external_isr);
_interrupt_controller_unmask(MCF5225_INT_EPORT0_EPF1);
while(1)
{
/* See if the PIT has timed out */
temp = PCSR0;
if (temp & PIT_INTRPT_FLAG)
{
PCSR0 |= PIT_INTRPT_FLAG;
counter++;
if (counter == 1000)
{
outCnt++;
outCnt &= 0x7;
if (outCnt == 0)
{
/* Clear all bits including interrupt indication */
PORTTC = 0;
}
else
{
tmpU8 = PORTTC;
tmpU8 &= ~0x7;
tmpU8 |= outCnt;
PORTTC = tmpU8;
}
counter = 0;
}
}
}
This counts from 1 to 7 using LED1 to LED3 on the board, and pressing SW2 causes a kernel interrupt and lights LED4. When the LED1 to LED3 goes to 0, it also clears LED4 so you can take another measurement. I apologize for the code not being commented very well, but hopefully this will help somebody not waste an hour or two trying to get this to work.
Oh yeah, to answer gmnelson, this does put the vector table in RAM which consumes the 1KB of RAM. In production you might want to save the real vector table in flash so you don't lose this space.
Message Edited by HSpahr on 2009-11-11 03:07 PM