KE06 IRQ Interrupt and GPIO reset status.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KE06 IRQ Interrupt and GPIO reset status.

ソリューションへジャンプ
2,235件の閲覧回数
donghoha
Contributor II

I use MKE06Z128VLK4 Kinetis mcu and KEXX_DRIVERS_V1.2.1_DEVD.

This package have no IRQ interrupt driver and project source code.

Can I get IRQ Interrupt examples?

I use IAR EW-ARM.

And I have one more question.

I wonder GPIO status while reseting.

Measured result is about 3.6V. Is this right?

Is it input or output status?

Thank you.

ラベル(2)
タグ(4)
1 解決策
1,643件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Dongho ha,

   I have a IRQ  IAR sample code for KEA128, this code also based on the KEXX_DRIVERS_V1.2.1_DEVD.

  I have attached the KEA128_IRQ for your reference.

  The code function is get the PTI0 rising IRQ interrupt. the IRQ module in KEA128 is the same as KE06, so you can refer to my source code directly.


int main (void);
void RTC_Task(void);
void IRQ_Isr(void);
  unsigned int jjtest=0;
/******************************************************************************
* Global functions
******************************************************************************/
void IRQ_Isr(void)
{

  IRQ->SC |= IRQ_SC_IRQACK_MASK;

}

void IRQ_Init(void)
{
  SIM->PINSEL |=  0x01; //PTI0
  SIM->SCGC |= SIM_SCGC_IRQ_MASK;
 

  IRQ->SC = IRQ_SC_IRQEDG_MASK |
           IRQ_SC_IRQPE_MASK |
           IRQ_SC_IRQIE_MASK ;//|
           //IRQ_SC_IRQMOD_MASK;
 
 
  NVIC_EnableIRQ(IRQ_IRQn);
}
int main (void)
{
    unsigned int test=0;
    unsigned char u8Ch;
    RTC_ConfigType  sRTCConfig;
    RTC_ConfigType  *pRTCConfig = &sRTCConfig;       

    /* Perform processor initialization */
    sysinit();
    printf("\nRunning the KE06 platinum project.\n");
    LED0_Init();        //red led
    LED1_Init();        //green led
    LED2_Init();        //blue led
    
    LED0_Off();
    LED1_Off();
    LED2_Off();

    /* configure RTC to 1Hz interrupt frequency */
    pRTCConfig->u16ModuloValue = 9;                                      
    pRTCConfig->bInterruptEn   = RTC_INTERRUPT_ENABLE;     /* enable interrupt */
    pRTCConfig->bClockSource   = RTC_CLKSRC_1KHZ;          /*clock source is 1khz*/
    pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_100;    /*prescaler is 100*/

    RTC_SetCallback(RTC_Task);
    RTC_Init(pRTCConfig);
    IRQ_Init();

    printf("Please enter any character which will echo...\n");
    /* echo chars received from terminal */
    test = jjtest;
    while(1)
    {
        u8Ch = UART_GetChar(TERM_PORT);
        UART_PutChar(TERM_PORT, u8Ch);
        LED2_Toggle();
    }
}

Another question, the port in default is the input, but if you want to use the GPIO input, you also need to configure GPIOx_PDIR to enable the general purpost input function.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

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

元の投稿で解決策を見る

8 返答(返信)
1,643件の閲覧回数
donghoha
Contributor II

Thank you for answer.

This is good idea.

I will try other ISR.

Thank you.

0 件の賞賛
返信
1,643件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Dongho,

   You are welcome!

   If your question is solved, please help me to mark the correct answer to close this CASE.

   Thank you very much.


Have a great day,
Kerry

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

1,643件の閲覧回数
donghoha
Contributor II

Dear Kerry Zhou.

I am sorry to send you a message without your permission.

I tried KE06 FTM EPWM function.

I used FTM2-CH1 port.

I am trying FTM EPWM using KEXX_DRIVERS_V1.2.1_DEVD example.

This example operate well. (0~100% variation for one second)

Modulation frequency : 1kHz.

 

But all FTM2 port output 1kHz pulse with fixed duty.

[ PTC0(FTM2CH0),PTC2(FTM2CH2),PTC3(FTM2CH3),PTB4(FTM2CH4),PTB5(FTM2CH5) ]

 

FTM2CH0~FTM2CH5 output 1Khz pulse regardless of GPIO setting(Input/Output).

 I want to use other GPIO pins(PTC0, PTC2, PTC3, PTB4, PTB5) for input or output normaly.

Can't I use FTM2-CH1(PTC1) with GPIO pins(PTC0, PTC2, PTC3, PTB4, PTB5) for input or output normaly.

if FTM Module change , (using FTM0, FTM1) , MCU be halted.

So, If you have FTM0, FTM1 EPWM examples then can you send to me them.

 

Can you look at my question?

Once again, I am sorry to send you a message without permission.

Thank you.

0 件の賞賛
返信
1,643件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dongho,

   Because this post original question is closed, and this post is a little old.

  Then, if you have the new question, please create the new question post, we will help you in your new post.

   After you create the new post, if you still want I to provide service for you, you can @Kerry Zhou in your post content, then I will answer you in your new post about your new question.

    Please also tell me your chip full name, and the IDE you are using now.

   Thanks a lot for your understanding, please create the new question post now.


Have a great day,
Kerry

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

1,644件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Dongho ha,

   I have a IRQ  IAR sample code for KEA128, this code also based on the KEXX_DRIVERS_V1.2.1_DEVD.

  I have attached the KEA128_IRQ for your reference.

  The code function is get the PTI0 rising IRQ interrupt. the IRQ module in KEA128 is the same as KE06, so you can refer to my source code directly.


int main (void);
void RTC_Task(void);
void IRQ_Isr(void);
  unsigned int jjtest=0;
/******************************************************************************
* Global functions
******************************************************************************/
void IRQ_Isr(void)
{

  IRQ->SC |= IRQ_SC_IRQACK_MASK;

}

void IRQ_Init(void)
{
  SIM->PINSEL |=  0x01; //PTI0
  SIM->SCGC |= SIM_SCGC_IRQ_MASK;
 

  IRQ->SC = IRQ_SC_IRQEDG_MASK |
           IRQ_SC_IRQPE_MASK |
           IRQ_SC_IRQIE_MASK ;//|
           //IRQ_SC_IRQMOD_MASK;
 
 
  NVIC_EnableIRQ(IRQ_IRQn);
}
int main (void)
{
    unsigned int test=0;
    unsigned char u8Ch;
    RTC_ConfigType  sRTCConfig;
    RTC_ConfigType  *pRTCConfig = &sRTCConfig;       

    /* Perform processor initialization */
    sysinit();
    printf("\nRunning the KE06 platinum project.\n");
    LED0_Init();        //red led
    LED1_Init();        //green led
    LED2_Init();        //blue led
    
    LED0_Off();
    LED1_Off();
    LED2_Off();

    /* configure RTC to 1Hz interrupt frequency */
    pRTCConfig->u16ModuloValue = 9;                                      
    pRTCConfig->bInterruptEn   = RTC_INTERRUPT_ENABLE;     /* enable interrupt */
    pRTCConfig->bClockSource   = RTC_CLKSRC_1KHZ;          /*clock source is 1khz*/
    pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_100;    /*prescaler is 100*/

    RTC_SetCallback(RTC_Task);
    RTC_Init(pRTCConfig);
    IRQ_Init();

    printf("Please enter any character which will echo...\n");
    /* echo chars received from terminal */
    test = jjtest;
    while(1)
    {
        u8Ch = UART_GetChar(TERM_PORT);
        UART_PutChar(TERM_PORT, u8Ch);
        LED2_Toggle();
    }
}

Another question, the port in default is the input, but if you want to use the GPIO input, you also need to configure GPIOx_PDIR to enable the general purpost input function.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

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

1,643件の閲覧回数
donghoha
Contributor II

Thank you so much.

I succeed IRQ interrupt operation by your code.

Sorry, Let me ask you one more question.

Source code that you send to me has no SetCallback function.

How can it  operate interrupt service routine?

Thank you.

0 件の賞賛
返信
1,643件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Dongho Ha,

 I didn't add the call back function, I execute the code directly in the ISR function, because I think this method will shorten the ISR execution time.

 But If you still want to use the call back function.

 You can refer to this UART call back code to modify it.

void UART_SetTxDoneCallback(UART_Type *pUART, UART_TxDoneCallbackType pfnCallback)
{
    uint8_t u8Port = ((uint32_t)pUART-(uint32_t)UART0)>>12;
    UART_TxDoneCallback[u8Port] = pfnCallback;
}

void UART_HandleInt(UART_Type *pUART)
{
    uint8_t   u8Port;
    uint8_t   *pRdBuff;
    uint8_t   *pWrBuff;  
    volatile uint8_t read_temp = 0;
    
    u8Port = ((uint32_t)pUART-(uint32_t)UART0)>>12;
    
    /* check overrun flag */
    if(UART_CheckFlag(pUART,UART_FlagOR))
    {
        read_temp = UART_ReadDataReg(pUART);     
    }
    
    /* check receiver */
    else if(UART_IsRxBuffFull(pUART))       
    {
        /* there's data received in rx buffer */
        pRdBuff = pUART_RxBuff[u8Port];                     /* get user read buffer */
        read_temp = UART_ReadDataReg(pUART);
        pRdBuff[gu16UART_RxBuffPos[u8Port]++]= read_temp;   /* save received data */
        //pRdBuff[gu16UART_RxBuffPos[u8Port]++] = UART_ReadDataReg(pUART);
        if(gu16UART_RxBuffPos[u8Port] == gu32UART_BuffSize[u8Port])
        {    
            /* User read buffer is full, end receive */
            UART_DisableRxBuffFullInt(pUART);
            if (UART_RxDoneCallback[u8Port])
            {
                /* call back function to tell user that rx is done */
                UART_RxDoneCallback[u8Port]();
            }
        }    
    }
    /* check transmitter */
            else if(UART_IsTxBuffEmpty(pUART))
    {
        if(gu16UART_TxBuffPos[u8Port] != gu32UART_BuffSize[u8Port])
        {
            /* user tx buffer not empty */
            pWrBuff = pUART_TxBuff[u8Port];
            UART_WriteDataReg(pUART, pWrBuff[gu16UART_TxBuffPos[u8Port]++]);     
        }  
        else
        {
            UART_DisableTxBuffEmptyInt(pUART);
            if (UART_TxDoneCallback[u8Port])
            {
                /* call back function to tell user that tx is done */
                UART_TxDoneCallback[u8Port]();
            }
        }
    }
    else
    {
        /* default interrupt */
    }
}

In main

    UART_SetTxDoneCallback(UART1, UART_SendDone);
    UART_SetCallback(UART_HandleInt);

Wish it helps you!


Have a great day,
Kerry

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

1,643件の閲覧回数
mjbcswitzerland
Specialist V

Hi

I have made a short video for you explaining the IRQ operation on the KE06:https://youtu.be/-Qjq_HB_KbI

You can get all code for the KE06 and the IRQ interface at the links below (for IAR, Keil, KDS, CW, S32, Rowley, Atollic, CooCox, Green Hills, GCC standalone and VS).

The pins all have a default state (see the user's manual for each one). They will never default to outputs - most to inputs. Inputs which may have pull-ups enabled, which you will measure as a high voltage (but with high impedance).

Regards

Mark

http://www.utasker.com/kinetis.html
http://www.utasker.com/kinetis/FRDM-KE06Z.html