GPIO IRQ fails

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

GPIO IRQ fails

Jump to solution
1,157 Views
Ardoster
Contributor III

Hi

 

I'm trying to link an IRQ to an extern IRQ pin. I've been reading the manuals and consulting different threads in this forum, but I can't see where the error is. Have I to modify or enable something in the BSP or PSP?

 

This is my code, maybe you know what's happening.

 

// define inputsconst uint_32 g_GPIOS_Inputs[] = { GPIO_PORT_NQ | GPIO_PIN1 | GPIO_PIN_IRQ_FALLING, GPIO_LIST_END };static MQX_FILE_PTR g_GPIOS_OutputPort = NULL;static MQX_FILE_PTR g_GPIOS_InputPort = NULL;void irq_callback();// current value of output gpiosboolean g_GPIOS_OutputsValue[PROJECT_MAX_OUTPUTS] = {0};void irq_callback(){ static u8 counter=0;  counter++; }/** GPIOS_Init *  Initializes all gpios in the hardware  *  @return Error code */error_t GPIOS_Init(){ // configure gpios outputs g_GPIOS_OutputPort = fopen("gpio:write", (char_ptr)&g_GPIOS_Outputs); if (g_GPIOS_OutputPort == NULL){  PrintError("GPIO Init failed. Exiting...", ERROR_MQX_GPIO);  _time_delay(PROJECT_MQX_DELAY_TO_EXIT);  _mqx_exit((_mqx_uint)ERROR_MQX_GPIO); } // configure gpios inputs g_GPIOS_InputPort = fopen("gpio:read", (char_ptr)&g_GPIOS_Inputs); if (g_GPIOS_InputPort == NULL){  PrintError("GPIO Init failed. Exiting...", ERROR_MQX_GPIO);  _time_delay(PROJECT_MQX_DELAY_TO_EXIT);  _mqx_exit((_mqx_uint)ERROR_MQX_GPIO); }  ioctl(g_GPIOS_InputPort, GPIO_IOCTL_SET_IRQ_FUNCTION, (pointer) &irq_callback); ioctl(g_GPIOS_InputPort, GPIO_IOCTL_ENABLE_IRQ, NULL);  //GPIOS_InstallCallbackIRQ(&MAIN_Callback); //GPIOS_IRQEnable(TRUE);  }

 Thanks in advance.

 

Regards

 

0 Kudos
1 Solution
584 Views
Ardoster
Contributor III

Hello

 

I've solved the problem. It was something related with hardware. I don't understand very well what the problem was, but now is working correctly.

 

Because it was a problem on my side, could some admin delete this thread??? Is a nonsense having this thread when the problem was nothing related to MQX or Coldfire.

 

Thanks and sorry

 

 

View solution in original post

0 Kudos
8 Replies
584 Views
Ardoster
Contributor III

Sorry, but I forgot to say I'm working on M52259DEMO using MQ X3.7. Maybe that helps to solve this mistery.

 

 

 

0 Kudos
584 Views
c0170
Senior Contributor III

Hello ardoster,

 

There come to my mind in the first place :

I can't locate in your code snippet if you added the ISR to the MQX (int_install_isr() ) ? Did you enable gpio interrupt source? 2 function calls are commented and can't see what's their agenda.

 

Regards,

MartinK

 

 

0 Kudos
584 Views
Ardoster
Contributor III

The two functions you refer are commented because they call the two ioctl calls written before them.

 

About the int_install_isr(), that is more interesting. I'm not calling that function. That can be the explanation. But I've been following this https://community.freescale.com/message/67920#67920and that function is not being called.

 

I'll keep trying.

 

Thanks you a lot of

 

 

 

0 Kudos
584 Views
Ardoster
Contributor III

Well, I've been making inquiries and I've seen the function _int_install_isr is being called by fopen when in its pins struct is added the flag *IRQ*, as for example GPIO_PIN_IRQ_FALLING.

 

I've verified this function is being correctly called, but the interruption never happens. I don't know what to do.

 

Thanks you

 

0 Kudos
584 Views
c0170
Senior Contributor III

Hello,

 

still no interrupt raised? If you really followed the thread you included, your application should be running.

 

Check the result of the call _int_get_isr to verify if your function was tight to the vector number.

Look at the registers of the MCU if PORTS registers are properly set up (GPIO function) and what about Interrupt controller (IMRHn,IMRLn) ?

Does the logic level of the pin really change? Is the pin in logic high (because of pull-up) ?

Silly questions,but they cause a trouble.

 

Regards,

MartinK

0 Kudos
584 Views
Ardoster
Contributor III

Hello

 

Yes. Thanks for your reply. Unfortunately I'm still having problems. I can't understand how a such easy thing can make so much troubles! Smiley Sad

 

Using this pinout list...

 

const uint_32 g_GPIOS_Inputs[] = {  GPIO_PORT_AN | GPIO_PIN0,  GPIO_PORT_NQ | GPIO_PIN1 | GPIO_PIN_IRQ_FALLING,  GPIO_PORT_NQ | GPIO_PIN7,  GPIO_LIST_END };

 

... I've just made the next verifications:

 

1) I'm able to read the pin AN0

2) I'm able to read the pin NQ7 (not linked to the interruption).

3) The GPIO NQ registers are correct:

 

PORTNQ = 0x7E DDRNQ = 0x00 (all pins configured as inputs)SETNQ = 0xAACLRNQ = 0x00PNQPAR = 0x880 (pins 1 and 7 configured as GPIO function)

 4) IMRL0 is correct.

 

IMRL0 = 0x667bdffc(bit 1 is 0, so the interrupt source number 1 (EPORT1) is enabled)

 5) Using _int_get_isr(MCF5225_INT_EPORT0_EPF1) I obtain the ISR function address. This pointer is addressing to gpio_eport_irq(), in file io_gpio_mcf5225.c. So it is correct. In this function, examining the code, is where MQX must locate my ISR function. But this interruption never happens.

 

6) The only thing is strange is i CAN'T read the value of pin NQ1 when this pin is linked to the falling interrupt (GPIO_PIN_IRQ_FALLING). In other words: I have a task reading every second the value of pin NQ1, and I can see how this value changes (so the HW is correct) when this pin is NOT linked to the falling edge interrupt. But when I link this pin to the interrupt, the value printed by my task is always 0.

 

What do you think? I need holidays!

 

Thanks you in advance

 

0 Kudos
585 Views
Ardoster
Contributor III

Hello

 

I've solved the problem. It was something related with hardware. I don't understand very well what the problem was, but now is working correctly.

 

Because it was a problem on my side, could some admin delete this thread??? Is a nonsense having this thread when the problem was nothing related to MQX or Coldfire.

 

Thanks and sorry

 

 

0 Kudos
584 Views
Ardoster
Contributor III

Hi again

 

I've been wrong these last two weeks. It's not a hardware related problem, but a software problem. The problem is that I must initializalize the rtcs module before initializing the gpios interruptions. Doing this, the problem dissapear.

 

Do you have any explanation about this problem????

 

Thanks you.

0 Kudos