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
Solved! Go to Solution.
Hi,
I have noticed that you have mcf5225_int_init and _int_install_isr in wrong order.
First you should install isr - that means connect interrupt with service routine.
Then interrupt should be initialized - set int level, sublevel , mask/unmask.
PetrL
Hi,
I have noticed that you have mcf5225_int_init and _int_install_isr in wrong order.
First you should install isr - that means connect interrupt with service routine.
Then interrupt should be initialized - set int level, sublevel , mask/unmask.
PetrL
Hi
A perhaps very silly question: What's GPT? I haven't found it neither MQX User's Manual nor Reference Manual.
Thanks you.
Regards
GPT is ColdFire peripheral module - General Purpose Timer. See chip reference manual.
MQX does not have driver for it, therefore you can not find it manual..
Regards,
PetrL