MCF5213 trouble getting started

cancel
Showing results for 
Search instead for 
Did you mean: 

MCF5213 trouble getting started

1,888 Views
josh_outerspace
Contributor I
I am using the M5213EVB with codewarrior and the C stationary.

I am getting a problem when trying to use interrupts. Here is what I am doing:

1. Make interrupt function preceded with __interrupt__ keyword. It is a PIT interrupt, it looks like this

__interrupt__ void my_pit0_irq(void)
{//vector 64+55=119, source =55
MCF_PIT0_PCSR = (108)||(13)||1;
MCF_PIT0_PMR = 0xffff;
MCF_GPIO_PORTAN ^= 0xff; //flip last 4 bits
counter++;
}

2. In main function, I add these lines of code for interrupt:

MCF_PIT0_PCSR = (68)||(13)||1;
//2^10 prescaler, enable irq, enable module

MCF_INTC_ICR55 = (33)||(3);
MCF_INTC_IMRH = ~(123); //enable irq 55

3. In vectors.s I change this-

vector119: .long asm_exception_handler

to this-

vector119: .long my_pit0_irq


The reason I changed vector 119 is because the pit0 irq is number 55 and 55+64=119.
When I compile this, I get error!

error- unknown identifier in vectors.s!!

The identifier is the EXACT SAME as my interrupt function!!!!! How can this happen? I am very frustrated with freescale right now. I have used many products and have never had such an issue getting an interrupt to work!
Labels (1)
0 Kudos
3 Replies

385 Views
airswit
Contributor III
it also seems as if you may be writing your code incorrectly. your 'ors' should be '|' rather than '||', as the latter is a boolean operation...be careful with those, as you are assigning a 1 to many things!
0 Kudos

385 Views
josh_outerspace
Contributor I
Yes, || is a careless error. I have made this work with the set_handle function and not touching the assembly file.
0 Kudos

385 Views
SimonMarsden_de
Contributor II
The file 'vectors.s' is an assembler file, so it knows nothing about the interrupt handler in your C code.

You need to add the following declaration to the start of vectors.s:

.extern _my_pit0_irq


Note that there is a leading underscore '_' character there. This is because the C compiler always adds an underscore to the name of any C function; to get the assembler to match, you need to add the underscore explicitly.

Hope this helps
0 Kudos