AnsweredAssumed Answered

Help defining interrupts with MQX

Question asked by Jaime Rodriguez on Apr 25, 2009
Latest reply on Sep 13, 2009 by Petr Lukas

Hi,
I am using GPT in order to detect falling edges with Input Capture. I have done a project without operating system and

interrupts are working fine, however, when I try to add a module into BPS to drive GPT and detect falling edges,

interrupts are not working.
Below is my initialize function simplified to manage only Timer Zero. I am using the same values for register as the

project working without OS. I am also installing interrupts using the functions provided for with MQX.
What could the problem be?
What am I missing?

uint_32 GPT_Initialize
(
 //Número del timer
 uint_8 tim_num, pointer isr
)
{ /* Body */
   volatile PSP_INTERRUPT_TABLE_INDEX index;
   VMCF5225_STRUCT_PTR reg_ptr = _PSP_GET_IPSBAR(); 

   volatile GPT_REG_STRUCT_PTR     gpt_reg_ptr;

   void     (_CODE_PTR_ result)(pointer);
   uint_32   return_code = GPT_OK;
  
   gpt_reg_ptr = (pointer)(&((VMCF5225_STRUCT_PTR)_PSP_GET_IPSBAR())->GPT);

   switch(tim_num)
   {
           gpt_reg_ptr->GPTSCR1 &= ~MCF_GPT_GPTSCR1_TFFCA;
              case(0):
                 index = MCF5225_INT_TIMA_C0F;
                    reg_ptr->GPIO.PTAPAR |= (MCF_GPIO_PTAPAR_PTAPAR0(1) );
                    gpt_reg_ptr->GPTDDR  &= ~ MCF_GPT_GPTDDR_DDRT0;
                    gpt_reg_ptr->GPTIOS  &= ~MCF_GPT_GPTIOS_IOS0;
                    gpt_reg_ptr->GPTSCR1 &= ~(MCF_GPT_GPTSCR1_TFFCA|MCF_GPT_GPTSCR1_GPTEN); 
                    gpt_reg_ptr->GPTCTL2 |= MCF_GPT_GPTCTL2_EDG0A;
                    gpt_reg_ptr->GPTCTL2 &= MCF_GPT_GPTCTL2_EDG0B;
                    gpt_reg_ptr->GPTIE  |= MCF_GPT_GPTIE_CI0;
                    gpt_reg_ptr->GPTSCR2 = MCF_GPT_GPTSCR2_PR(1);
                    reg_ptr->GPIO.PTAPAR = 0x00;
                    reg_ptr->GPIO.PTAPAR |= MCF_GPIO_PTAPAR_PTAPAR0(1);
                    if ( _mcf5225_int_init(MCF5225_INT_TIMA_C0F, GPT_C0F_INT_LEVEL, GPT_C0F_INT_SUBLEVEL, TRUE) != MQX_OK)
                    {
                         return (GPT_INT_ENABLE_FAILED);
                    }
                    gpt_reg_ptr->GPTFLG1  |= MCF_GPT_GPTFLG1_CF0;
                    gpt_reg_ptr->GPTFLG2  |= MCF_GPT_GPTFLG2_TOF;
                    gpt_reg_ptr->GPTSCR2 &= ~MCF_GPT_GPTSCR2_TCRE;
                    gpt_reg_ptr->GPTSCR1 |= MCF_GPT_GPTSCR1_GPTEN;
                    result = _int_install_isr (index, (void (_CODE_PTR_))isr, (pointer)gpt_reg_ptr);
                    if(result == NULL)
                    {
                         return_code = _task_get_error();
                    }
                    default: break;
   }
    return return_code;
} /* Endbody */

Regards,

Jaime

Outcomes