KL05 unable to enable PTA9 port interrupt

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

KL05 unable to enable PTA9 port interrupt

Jump to solution
902 Views
matthew5
Contributor I

Hi all,

I'm working on a project with the KL05 freedom board (also having the same issue with a custom board with the same MKL05Z32VFM4 microcontroller). I'm developing the code using Kinetis Design Studio 3.

The project involves using 3 switches which triggers their respective interrupts. The buttons are designated to PA9, PA10, and PA11. 

I have managed to get the interrupt request for PA10 and PA11 to function successfully -- button presses result in entering the PORTA_IRQHandler. However, I am unable to get PA9 specifically to function. While stepping through the code with the debugger, successful set up of the PCR registers for PA10 and PA11 have the value of 0xa0107. However, the same setup procedure for PA9 results in a read register value of 0x107.

Essentially, this is what I have been doing for pin assignment setup for my button inputs:

SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK; //enable clocks for ports A and B

NVIC_SetPriority(PORTA_IRQn, 1);   
NVIC_EnableIRQ(PORTA_IRQn);

PORTA_PCR10 = (PORT_PCR_MUX(1) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK | PORT_PCR_PFE_MASK);
GPIOA_PDDR &= ~(1<<10);

PORTA_PCR9 = (PORT_PCR_MUX(1) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK | PORT_PCR_PFE_MASK );
GPIOA_PDDR &= ~(1<<9);

PORTA_PCR11 = (PORT_PCR_MUX(1) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK | PORT_PCR_PFE_MASK);
GPIOA_PDDR &= ~(1<<11);

__enable_irq();   //enable global interrupt

//later in the code, i configure the interrupt config bit of each register exclusively.

PORTA_PCR10 |= PORT_PCR_IRQC(10);

PORTA_PCR9 |= PORT_PCR_IRQC(10);

PORTA_PCR11 |= PORT_PCR_IRQC(10);

If anyone has dealt with the same issue with being unable to write to the register, what was the path taken to correcting the issue?

Thanks,

Matt

1 Solution
804 Views
mjbcswitzerland
Specialist V

Hi Matt

Unfortunately one has to be careful with the small devices since their ports don't all support usual features. Always check the ports summary table since the missing support is not normally noted anywhere in the chip's register section.

pastedImage_1.png

Also the SDK doesn't support checking for non-supported use.

I check with the uTasker project like this:

    INTERRUPT_SETUP interrupt_setup;                   // interrupt configuration parameters
    interrupt_setup.int_type       = PORT_INTERRUPT;   // identifier to configure port interrupt
    interrupt_setup.int_handler    = test_irq_4;       // handling function
    interrupt_setup.int_priority   = PRIORITY_PORT_A_INT; // interrupt priority level
    interrupt_setup.int_port       = PORTA;            // the port that the interrupt input is on
    interrupt_setup.int_port_bits  = (PORTA_BIT9 | PORTA_BIT10 | PORTA_BIT11);
    interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON | ENABLE_PORT_MODE); // set the pin to port mode - this is needed if the pin is disabled by default otherwise the pull-up/LLWU functions won't work
    fnConfigureInterrupt((void *)&interrupt_setup);    // configure interrupt

and its KL05 simulator points out the restriction to avoid losing time or making HW design errors before testing is performed:

pastedImage_3.png

Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

View solution in original post

3 Replies
805 Views
mjbcswitzerland
Specialist V

Hi Matt

Unfortunately one has to be careful with the small devices since their ports don't all support usual features. Always check the ports summary table since the missing support is not normally noted anywhere in the chip's register section.

pastedImage_1.png

Also the SDK doesn't support checking for non-supported use.

I check with the uTasker project like this:

    INTERRUPT_SETUP interrupt_setup;                   // interrupt configuration parameters
    interrupt_setup.int_type       = PORT_INTERRUPT;   // identifier to configure port interrupt
    interrupt_setup.int_handler    = test_irq_4;       // handling function
    interrupt_setup.int_priority   = PRIORITY_PORT_A_INT; // interrupt priority level
    interrupt_setup.int_port       = PORTA;            // the port that the interrupt input is on
    interrupt_setup.int_port_bits  = (PORTA_BIT9 | PORTA_BIT10 | PORTA_BIT11);
    interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON | ENABLE_PORT_MODE); // set the pin to port mode - this is needed if the pin is disabled by default otherwise the pull-up/LLWU functions won't work
    fnConfigureInterrupt((void *)&interrupt_setup);    // configure interrupt

and its KL05 simulator points out the restriction to avoid losing time or making HW design errors before testing is performed:

pastedImage_3.png

Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

803 Views
matthew5
Contributor I

Hey Mark,

Thanks for replying to my question and providing the necessary information that I needed! 

I was looking at section 11.6.3 External Interrupts which said the PORT module was available in all digital pin muxing modes when enabled. Bummer that I missed the vital information you linked!

0 Kudos
804 Views
mjbcswitzerland
Specialist V

Matt

11.6.3 informs that the interrupt is available also when the pin is configured not as a GPIO but as a peripheral - eg. if a UART Rx pin is used it could also generate an interrupt on each input edge (for example) as well as being connected internally to the UART. This is in fact a nice feature to have (when the interrupt is supported on the individual GPIO)!

Regards

Mark

[uTasker project developer for Kinetis and i.MX RT]

0 Kudos