Interrupt handling on a MKV10Z32VLC7 and MK22FN512VLH12

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

Interrupt handling on a MKV10Z32VLC7 and MK22FN512VLH12

1,380 Views
denismatt
Contributor I

Hi all, i own a MKV10Z32VLC7 and a MK22FN512VLH12. I would like to program in C, so close as possible to the hardware. Now i made run the UART0, sending and receiving works fine, but receive with polling only. I want to use the Interrupt, so i set the Bit Nr 6 for the TCIE in the Uart0_C2 Register. How can i handle the Interrupt now ? I tried it with

static void UART0_IRQHandler(void)

{IRQ_Counter++;}   //test

but this function never been called yet, the counter stays at zero.

Can everyone explaine the principle ? And also wich of the commands in the startup file ist necessary, because i intend to keep only the minimum of commands and functions in the startup routine.

Labels (1)
Tags (1)
0 Kudos
6 Replies

908 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

NXP provides the MCUXpresso SDK software for both Kinetis product, which also provide UART interrupt example code.

Please visit here to config and download the updated KSDK software package.

The UART interrupt example located at below default folder:

..\SDK_2.2_FRDM-KV10Z\boards\frdmkv10z\driver_examples\uart\interrupt


Have a great day,
Ma Hui

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

0 Kudos

908 Views
denismatt
Contributor I

Hi Hui_Ma,

Hi Mark,

first, thank you for the fast responsing ! It's not working yet but i think i am very close to the solution.

I own no experimental or evaluation Board, i build my own developer Board. It hangs directly on the Programmer (NXP LPC-Link 2) and i work with the KDS 3.2.0. With this Code, the MCU hangs when should enter the Interrupt routine:

////////////

void UART0_IRQHandler(void)
{

   IRQ_Counter++;
    COM0_c=UART0_D;
}

   void COM0_Init(void)
{
   PORTA_PCR1=0x00000200;   // Pin 13 RXD0 (ALT2)
   PORTA_PCR2=0x00000200;   // Pin 14 TXD0 (ALT2)

   SIM_SCGC4|=SIM_SCGC4_UART0_MASK;   // Enable UART Clock

   uint16_t SBR=40;uint8_t BRFA=22;  //Set Baud Rate 115200
   UART0_BDH=(SBR>>8)&0x1F;
   UART0_BDL=SBR&0xFF;
   UART0_C4=BRFA;

    // Enable
    UART0_C1=0;     // Same as reset value
    UART0_C2=0x0C;    // Transmitter and Receiver
    UART0_C3=0;
    UART0_C5=0;
    UART0_MODEM=0;
    UART0_PFIFO=0;

    UART0_C2=0x2C;    // RIE

    NVIC_EnableIRQ(12);
}

////////////

In the "ProcessorExpertProject.map" the correspondin Handler is set to 0x00000528, like many others. A default Handler ?

How can i bend it to my Function UART0_IRQHandler ?

0 Kudos

908 Views
denismatt
Contributor I

Now it works. The reason why it was not working was because i forgot to read the UART0_S1 Register to clear the interrupt flag. Updated routine:

void UART0_IRQHandler(void)
{
    uint8_t s;

   s=UART0_S1;
   IRQ_Counter++;
   COM0_c=UART0_D;
}

The recommended example codes gave me also hints how to handle an interrupt. Many thanks !

0 Kudos

908 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Please refer below document about Interrupt handling with KSDK and Kinetis Design Studio:

https://community.nxp.com/docs/DOC-104352 

Wish it helps.


Have a great day,
Ma Hui

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

908 Views
denismatt
Contributor I

Hi Ma Hui,

thanks, that will be helpful when i want to refine the interrupt functions. It also make the vtor settings.

To program the core directly seems to be unable anyway or at least more complicated because the chapter 5 of the Cortex-M0+ Technical Reference manual has no much information:

http://infocenter.arm.com/help/topic/com.arm.doc.ddi0484b/DDI0484B_cortex_m0p_r0p0_trm.pdf 

0 Kudos

908 Views
mjbcswitzerland
Specialist V

Hi

You also need to enable the interrupt in the Cortex NVIC (Nester Vectored Interrupt Controller) and ensure that the handling routine is entered into the interrupt vector table (either in Flash or in SRAM, depending on the VTOR setting).

Try the firmware at the link below since it supports both of your boards and allows you to investigate the interrupt operation in its KV10 and K22 simulators in Visual Studio.

Regards

Mark

http://www.utasker.com/kinetis.html for quality Kinetis firmware

0 Kudos