Vamsee Somavarapu

Interrupt handling in M52233DEMO

Discussion created by Vamsee Somavarapu on Jul 13, 2007
Latest reply on Jul 19, 2007 by Vamsee Somavarapu
Hi
I am new to working with M52233DEMO and having some problem with handling interrupts.
I am trying a simple RTC interrupt through which I want to switch ON and OFF the LED alternatively everytime the interrupt is called. I want the interrupt to be called every 5 seconds. Here is the code I attempted:


Most of the code, I referenced from the following link :
http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=1043

Code:
#include <stdio.h>#include "common.h"int main(){ MCF_GPIO_DDRAN = 0x03; MCF_GPIO_SETAN |= MCF_GPIO_SETAN_SETAN0; // LED 1 ON at the start of the program   /*Interrupt controller */ MCF_INTC0_ICR63|=(MCF_INTC_ICR_IP(0x04)|MCF_INTC_ICR_IL(0x04)); MCF_INTC0_IMRH &=(~MCF_INTC_IMRH_MASK63); MCF_INTC0_IMRL &=(~MCF_INTC_IMRL_MASKALL);  asm {        move.l   #0x00002000,d0        move.w   d0,SR    }         /* Set real-time clock freq */ MCF_CLOCK_RTCDR = 25000000; /* Device-dependent */  MCF_RTC_HOURMIN = (uint32)0; MCF_RTC_HOURMIN = (uint32)0; MCF_RTC_SECONDS = (uint32)0;  MCF_RTC_ALRM_HM = (uint32)0; MCF_RTC_ALRM_SEC = (uint32)5;   // 5 seconds after the RTC enabled MCF_RTC_IER|= MCF_RTC_IER_ALM;  // ENABLE INTERRUPT FOR ALARM MCF_RTC_CR |= MCF_RTC_CR_EN;   printf("Hello World in C\n\r");  fflush(stdout);  while(1); // Idle  return 0;}__interrupt__ void rtc_handler(void){ static int flag=0; MCF_RTC_ISR = MCF_RTC_ISR_ALM;  // CLEAR FLAG  if(flag==0) {  MCF_GPIO_SETAN |= MCF_GPIO_SETAN_SETAN1; //LED2 ON  flag = 1;  } else {  MCF_GPIO_CLRAN &=(~MCF_GPIO_CLRAN_CLRAN1); // LED2 OFF  flag = 0; } }

In the interrupt vector table ( mcf52233_vectors.s), I changed the following:
#define _irq_handler      irq_handler
#define _rtc_handler  rtc_handler
#define _timer_handler    timer_handler //   ADDED THIS LINE
           ..
           ..

.extern _irq11_handler
.extern _rtc_handler  //  ADDED THIS LINE



      ..
      ..
vector7E:    .long    _irq_handler
vector7F:    .long    _rtc_handler    //RTC Interrupt      - Changed this line
/* start of IRQ2 */
vector80:    .long    _irq_handler
      ..
      ..
      ..

I am getting the following error :
"Exception vector name: Bus Error
PC where the exception happened: 0x40102700"

and my program is not running

Can anybody help me with this...

Thanks

Vamsee..

 

Outcomes