cancel
Showing results for 
Search instead for 
Did you mean: 

CAN interrupt doesn't occur

jkim71
Associate II
Posted on May 03, 2007 at 11:43

CAN interrupt doesn't occur

7 REPLIES 7
jkim71
Associate II
Posted on May 02, 2007 at 01:46

Hi.

I am ST micom beginner and have problem in CAN interrupt.

Currently CAN is test mode(loop back + silent mode) and after sending CAN message, interrupt doesn't seem to occur. Even CAN_IRQHandler is not reached.

Interrupt initializatin code is as follows.

--

// initialize the interrupt controller

EIC_IRQChannelConfig(CAN_IRQChannel, ENABLE);

EIC_IRQChannelPriorityConfig(CAN_IRQChannel, 1);

EIC_IRQConfig(ENABLE);

// initialize the CAN at a standard bitrate, interrupts enabled

CAN_Init(CAN_CR_IE, CAN_BITRATE_500K);

--

Where CAN_INIT is

--

void CAN_Init(u8 mask, u32 bitrate)

{

CAN_EnterInitMode(CAN_CR_CCE | mask);

CAN_SetBitrate(bitrate);

CAN_LeaveInitMode();

CAN_LeaveTestMode();

}

--

This code is from library of ST homepage, and I have no idea why this happens.

Please answer.

Thanks.

jkim71
Associate II
Posted on May 02, 2007 at 06:38

Thanks Zouh.

Original poster of the article you have linked was me.

But I can't understand your answer. You have attached screenshot of a program, but I do not use the program and I have no idea what relation is between UI of some program and function of IRQ.

Please explain me in more detail.

As for compiler, I am using ADS.

Thanks.

neuner
Associate II
Posted on May 03, 2007 at 05:15

Hi,

I had a look at the ST library, but haven't seen what might gone wrong.

Maybe before using CAN interrupt: Do you have checked an 'easier' interrupt like from a timer ? Just to be sure your startup code works fine and setup the EIC properly.

From your code I expect you are using the STR71x library.

For setting up the timer following code should work:

void TimerInstall( void )

{

/* configure priority of timer IRQ */

EIC_IRQChannelPriorityConfig(T1TIMI_IRQChannel, USR_IRQ_PRIORITY_TIM1);

/* enables global IRQ handling of EIC */

EIC_IRQConfig(ENABLE);

/* Enable Timer IRQ in interrupt controller */

EIC_IRQChannelConfig(T1TIMI_IRQChannel, ENABLE);

/* Initialize the Timer 1 registers to reset values */

TIM_Init ( TIM1 );

/* Configure the Timer 1 Prescaler */

TIM_PrescalerConfig ( TIM1, 0x00 );

/* Enable the Output Compare interrupt for the Timer 1 */

TIM_ITConfig ( TIM1, TIM_OCA_IT, ENABLE );

/* configure and enable Timer 1 */

TIM_OCMPModeConfig ( TIM1, TIM_CHANNEL_A, 0xFFFF, TIM_TIMING, TIM_HIGH );

}

--------

void T1TIMI_IRQHandler(void)

{

/*Clear the TIM1 interrupt flag Bit 14 OCFA */

TIM_FlagClear(TIM1, TIM_OCFA);

/* set next time to generate an interrupt */

/* to achieve 1ms at 24Mhz input frequency */

/* the value is set to 24000 ticks */

TIM1->OCAR += 24000;

}

-------------

If the code isn't reached, you may check the startup code. There might be somewhere an label called EIC_INIT.

Hope this helps.

Regards

Andreas

jkim71
Associate II
Posted on May 03, 2007 at 07:46

Thanks Andi_99 for your answer.

I have tested your code on timer, but T1TIMI_IRQHandler is not still reached.

And by 'startup code' you mean EIC_INIT routine in 71x_init.s assembler file?

neuner
Associate II
Posted on May 03, 2007 at 09:13

Hi JYKim,

yes. All the code which is executed before you reach ''void main(void)'' routine.

Could you use the startup routines (71x_init.s, ...) or did you adapt them to your compiler.

BTW: Which compiler / development environment do you have, maybe some other guys reading this have already adapted startup code for your environment or can provide a complete demo.

Regards

Andreas

jkim71
Associate II
Posted on May 03, 2007 at 09:41

Thanks Andi_99 for your quick answer.

I am using startup routine as was provided. and It's not easy to read assembly code though I once have programmed with the language.

I am using ADS 1.2 and Trace32.

And is there any way I can even find out whether interrupt was occured or not? thought IRQHandler is not reached.

Thanks.

neuner
Associate II
Posted on May 03, 2007 at 11:43

Hi JYKim,

after an interrupt occurs, the exception vector 0x00000018 is executed. This is the code address which is executed, in case an interrupt is signaled to the ARM7 core. If you add a breakpoint at this position, the program counter should break at 0x18. At this location (0x18) a jump to your interrupt routine is done. If you do a single step in your debugger you should reach IRQHandler which checks which interrupt is triggered. This calls then finally your interrupt handler of Timer, CAN, ...

If this is not called, you might check the manual for STR71. Usually the peripheral (timer, CAN, ...) sets an flag if it requests an interrupt or not. As I can see in the manual, also EIC provides such kind of flags IPR Register (Interrupt Pending Register). You also might check the IER (Interrupt Enable Register).

Hope you find this information useful.

Regards

Andreas