I²C - Interrupts gives "Exception vector name: address error"

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I²C - Interrupts gives "Exception vector name: address error"

3,912 Views
Student_Exams
Contributor I
Hello once again with another kind of problem,

I just created my own interrupt to react on i²c.
i did the following.

in File:    vectors.s
Code:
...#define _i2c_handler   i2c_handler....extern _i2c_handler...vector81: .long _i2c_handler

declaration of the interrupt in interrupt_handlers.c
Code:
__interrupt__ voidi2c_handler (void){ extern i2c_next_tx; printf("i2c_handler\n"); if (MCF_I2C_I2SR &= MCF_I2C_I2SR_RXAK)  i2c_next_tx = 0; else  i2c_next_tx = 1;  /* Clear the interrupt event */    MCF_I2C_I2SR &= ~MCF_I2C_I2SR_IIF;}

until here i think it is the same procedure as done with all the other interrupts in the vector table..

while debugging and comparing the registers i see that the iack cycle provides the the right vectornumber in the SWIACK...its #51, but all i get is a notice of codewarrior "Exception vector name: address error" as you can see in the image i attached.
it´s not clear to me, why he jumps to that kind of interrupt and to that address in memory.

i also tried to jump to the interrupt routine via the function "board_handle_interrupt" but this has no effect

maybe you´ll find something?

--
Alban Edit: title changed, too vague


Message Edited by Alban on 2007-06-15 08:35 PM
Labels (1)
0 Kudos
6 Replies

690 Views
mccPaul
Contributor I
Hi,
 
Did you just set up the interrupt vector, or have you also set up the interrupt level and priority?
 
What CPU?
 
Did you really mena to put &= in your if clause or should this be (MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK)?
 
There is some discussion on interrupts here that may help:
 
 
Cheers,
 
Paul.
0 Kudos

690 Views
Student_Exams
Contributor I
oh sry. Its the mcf52235evb

Thanks for correction in my if-clause. The debugger never reached this part, so i hadn´t mentioned yet.

What do you mean with setting up the vector exactly? i declared the routine as you you can see above. nothing else. i tried to use this function
Code:
ADDRESSmcf5xxx_set_handler (int vector, ADDRESS new_handler){    extern uint32 __VECTOR_RAM[];    ADDRESS old_handler;        old_handler = (ADDRESS) __VECTOR_RAM[vector];    __VECTOR_RAM[vector] = (uint32)new_handler;    return old_handler;}

...

mcf5xxx_set_handler (81, i2c_handler());

but the debugger starts immediatly to process the routine i2c_handler.
interrupt level and priority are set to 0x3


0 Kudos

690 Views
mjbcswitzerland
Specialist V
Hi

At a first glance it looks as though the interrupt vector is jumping to the address 0 (like a null pointer) where there is emply FLASH. I assume that you are downloading to and debugging from RAM(?)

Are you sure that the Vector Base Register is set up correctly (are other interrupts working?).
mcf5xxx_wr_vbr((unsigned long)__VECTOR_RAM); // set VBR to work with vectors in RAM

If you are working with interrupt vectors in RAM then the vectors.s file will not actually be used. It is only used if working from FLASH where the vector table is fixed - in this case mcf5xxx_set_handler() will also not be of any use. Since it looks more as though the vector table has a null pointer entry I would suspect that it is somewhere in RAM but not being initialised correctly. [check the value of VBR in the debugger. Then open a memory window at that address and check the interrupt vector addresses which are there.]

Note also that you can activate I2C support in the uTasker code by activating the define IIC_INTERFACE in config.h.

It is configured by
    IC_ICR_0_17 = IIC_INTERRUPT_PRIORITY;                                // define interrupts level and priority    fnSetIntHandler(IIC_VECTOR, (unsigned char *)_IIC_Interrupt);        // enter the handler routine    IC_IMRL_0 &= ~(IIC_PIF_INT_L | MASK_ALL_INT);
where fnSetIntHandler is equivalent to the one you are using.
The interrupt level and priority are user configurable in app_hw_m5223x.h (in SP4) and is defined as default to (INTERRUPT_LEVEL_2 | INTERRUPT_PRIORITY_2).

If you also activate TEST_IIC in application.c the code will read and write test data from/to an IIC EEPROM - see the description: http://www.utasker.com/docs/uTasker/uTaskerIIC.PDF

Regards

Mark

www.uTasker.com


 

0 Kudos

690 Views
Student_Exams
Contributor I
Hey mark...

that´s it.

the VBR was defined wrong. i added it like this and it works...

Code:
mcf5xxx_set_handler (int vector, ADDRESS new_handler){    extern uint32 __VECTOR_RAM[];    ADDRESS old_handler;        old_handler = (ADDRESS) __VECTOR_RAM[vector];    __VECTOR_RAM[vector] = (uint32)new_handler;    mcf5xxx_wr_vbr((uint32)__VECTOR_RAM);      //<----here we are    return old_handler;}

 
THX and and nice weekend :smileyhappy:
0 Kudos

690 Views
mjbcswitzerland
Specialist V
Ah, good..

Normally the  mcf5xxx_wr_vbr() initialiation is performed at start up (rather than in interrupt entry) so that it is only performed once.
In addition it will then also then catch exceptions in the normal exception handlers early on in the code.

See mcf52235_init() in m5223x.c in the uTasker project.
It is more of less the Freescale reference startup code which fills the vector table with an undefined interrupt handler and sets the VBR.

Regards

Mark
0 Kudos

690 Views
Student_Exams
Contributor I
update:

I implemented some code in the way described in the example of the other topic you gave me.
It looks like this now.
Code:
__interrupt__ void i2c_handler (void){ extern i2c_next_tx; printf("i2c_handler\n"); if (MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK)  i2c_next_tx = 0; else  i2c_next_tx = 1; //bei ACKN = 1 /* Clear the interrupt event */    MCF_I2C_I2SR &= ~MCF_I2C_I2SR_IIF;}void mcf52235_interrupt_init(uint8 source, uint8 ipl, void (*handler)(void)){ uint8 sysint = asm_set_ipl(7);  if (handler) {  MCF_INTC0_ICR(source) = (ipl & 0x3F);  mcf5xxx_set_handler (source + 64, (ADDRESS) handler); } asm_set_ipl(sysint);}int main(){ void (*handler)(void) = i2c_handler; init_main(); mcf52235_interrupt_init(0x11, MCF_INTC_ICR_IL(TIMER_NETWORK_LEVEL),handler); mcf5xxx_wr_sr(0x2000); mcf5xxx_irq_enable();        ...}

 after all the result is still the same :smileysad:

0 Kudos