FRDM-K66F SW2 and SDHC operation

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

FRDM-K66F SW2 and SDHC operation

1,086 Views
scott1
Contributor I

Hi community,

I was wondering whether the SW2 switch (using interrupts) and the SDHC can be used simultaneously on a FRDM-K66F? Can anyone point me to some sample code that has this configuration running?

Thank you very much.

/scott

Tags (1)
0 Kudos
8 Replies

963 Views
scott1
Contributor I

Kerry, actually your answer is incorrect. SW3 is on Port A (PTA10), but SW2 is on Port D (PTD11). My question concerns the sharing of SW2 and SDHC, which I believe are shared on PORT D (not A).

Can you please confirm my understanding and also re-address the shared interrupt for SHDC and SW2.

My question comes about from wanting to use SW3, SW2 and SDHC interface in my application.

Thank you and sorry for the confusion.

Scott

0 Kudos

963 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi scott reynolds,

  Sorry, really my mistake, SW2 is PTD11. 

  So you can use PORTD IRQ.

pastedImage_1.png

  But PORTD and SDHC still not the same IRQ, they will cause the different interrupt.

   If you want to use all the port and SDHC interrupt, you just need to enable the related interrupt IRQ, you don't need to use just one IRQ.

  If you still have questions about it, please kindly let me know.

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-----------------------------------------------------------------------------

0 Kudos

963 Views
scott1
Contributor I

Kerry,

Thank you for your response. I suppose my question is more a software best practice question.

There is one interrupt handler for port D - 'PORTD_IRQHandler', but in my case it needs to handle both the SDHC card inserted interrupt source and the SW2 interrupt source. 

From your SDMMC example code, in fsl_sdmmc_host.c you define the Port D interrupt handler: 

void SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER(void)

This function handles the SDMMC card inserted interrupt source.

In the general case, how would you recommend I structure my code if a) I wanted to integrate the supplied SDMMC code and b) I had other Port D interrupt handling requirements that were specific to my application only. Obviously I want to minimize the changes to fsl_sdmmc_host.c.

Perhaps migrating my application to FreeRTOS is something I need to consider.

Thank you for your input to this question.

Scott

0 Kudos

963 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello scott reynolds,

  Somewhat understand your confusing now.

  pastedImage_1.png

You means the PTD10(sd card detect pin) also use the PTD interrupt handler, and you also want to use the SW2 PTD11 interrupt right?

 But PTD10 and PTD11 share the same PORTD_IRQHandler, so you are confusing, right?

 If yes, you totally don't need to worry about it, please check these register:

pastedImage_2.png

So, in your PORTD_IRQHandler, you can check PORTD_PCR11[ISR] and the PORTD_PCR10[ISR].

If PORTD_PCR11[ISR] =1, it is the sd card interrupt.

If PORTD_PCR10[ISR]=1, it is your SW2 interrupt.

Wish it helps you!

If I misunderstand your questions, please also kindly let me know.

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-----------------------------------------------------------------------------

0 Kudos

963 Views
scott1
Contributor I

Thank you again Kerry for the timely and detailed response. I had mistakenly thought that the SDHC Card Detected hardware signal was on port A, and therefore the interrupt had to be shared with other Port A peripherals. Thank you for your clarification.

0 Kudos

963 Views
scott1
Contributor I

Thank you Kerry for your response. I understand that SW2 is on PORTA. My question is whether there is some code that shows how a port A interrupt handler can handle both the SDHC SD card interrupts and the SW2 interrupts. 

Thank you for your continued assistance with this matter.

Regards,
Scott

0 Kudos

963 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi scott reynolds,

    PortA and the SDHC interrupt are the different IRQ:

pastedImage_1.png

pastedImage_2.png

So you totally can use two Interrupt handler, why you need to use one port A interrupt handler to process both port and the SDHC interrupt handler?

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-----------------------------------------------------------------------------

0 Kudos

963 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi scott reynolds ,

   

  SW2 is the PTA10 pin, 

pastedImage_1.png

 If you are using the normal interrupt, when it is pressed, the code will enter the PORTA interrupt handler.

  After the interrupt exit, the code will run your SDHC code again. The SDHC still can be used.

  You can refer to the SDK code for FRDM-K66, then add your port interrupt.

  The SDK code can be downloaded from this link:

Welcome | MCUXpresso SDK Builder 

Wish it helps you!

If you still have questions about it, please kindly let me know.

  

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-----------------------------------------------------------------------------

0 Kudos