KL25Z GPIO simulation (Keil)

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

KL25Z GPIO simulation (Keil)

Jump to solution
2,318 Views
a_t
Contributor II

Is there any way to simulate a simple switch interrupt for KL25Z boards in Keil?

Currently, I have to manually set PDIR, ISFR and NVIC_ISPR. Is there anyway to simulate the behavior of an input switch? (for example, by changing the data, it automatically calls the interrupt)

1 Solution
1,477 Views
mjbcswitzerland
Specialist V

Hi

The uTasker project with Kinetis simulaton is free for non-commercial use.

The simulator doesn't work together with Keil but the code that it simulates is the same as Keil uses to build the project - that is, one develops and simulates in the simulator (i.e. using VisualStudio) and then cross-compiles in Keil to generate the target code and do any additional HW debugging.


Therefore it is "compatible" with Keil, IAR, KDS, CW etc. but doesn't actually run in these IDEs as simulation.

Regards

Mark

Kinetis: µTasker Kinetis support

KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support

For the complete "out-of-the-box" Kinetis experience and faster time to market


View solution in original post

0 Kudos
5 Replies
1,477 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello A T,

You also need configure  the interrupt of the pin use the "PORTx_PCRn" register.

pastedImage_0.png

Also configure the pin to GPIO function, enable the related interrupt.

For example : set PTA19 for GPIO interrupt when the pin is logic zero

SIM_SCGC5 = SIM_SCGC5_PORTA_MASK;

  PORTA_PCR19=PORT_PCR_MUX(1)|PORT_PCR_IRQC(0x08)|PORT_PCR_PE_MASK|PORT_PCR_PS_MASK;

enable_irq(87); //GPIOA Vector is 103. IRQ# is 103-16=87

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

void enable_irq (int irq)

{

    int div;

  

    /* Make sure that the IRQ is an allowable number. Right now up to 91 is

    * used.

    */

  

    /* Determine which of the NVICISERs corresponds to the irq */

    div = irq/32;

  

    switch (div)

    {

        case 0x0:

              NVICICPR0 = 1 << (irq%32);

              NVICISER0 = 1 << (irq%32);

              break;

        case 0x1:

              NVICICPR1 = 1 << (irq%32);

              NVICISER1 = 1 << (irq%32);

              break;

        case 0x2:

              NVICICPR2 = 1 << (irq%32);

              NVICISER2 = 1 << (irq%32);

              break;

    }            

}

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

then when you set the pta10 to zero , it will enter interrupt function.


Have a great day,
Alice

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

1,477 Views
a_t
Contributor II

Hello @Alice_Yang,

Thanks for your answer. Probably I have not expalined all the details. Basically, I have done all the setup. Everything works on the real board.

Now I want to simulate the behaviour in the Keil simulation mode.

In your example setting PTA19 to zero is like pushing a button. I want to simulate it in software. What should I do to simulate the same behaviour?

Thanks!

0 Kudos
1,477 Views
mjbcswitzerland
Specialist V

Hi

Complete (approx.) real-time Kinetis peripheral simulation (UART, USB, Ethernet, timers, ports, interrupts, DMA, ADC, etc.) is possible in the uTasker project.

In the IDE simulators (IAR, Keil, etc.) there is only really CPU instruction simulation that is very slow and doesn't include peripherals. In some cases there is limited peripheral operation (like a debug output) but it is best to read the Help in Keil to see what there atually is in the version that you are using.

Regards

Mark

Kinetis: µTasker Kinetis support

KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,477 Views
a_t
Contributor II

Hi Mark,

Thanks for the very helpful answer. I was looking at it to see whether it is compatible with Keil. But it is not free. Is it?

Would it be possible to find C programs that simulate at least some features/behaviours of the ports, interrupts and peripherals?

Thanks again.

0 Kudos
1,478 Views
mjbcswitzerland
Specialist V

Hi

The uTasker project with Kinetis simulaton is free for non-commercial use.

The simulator doesn't work together with Keil but the code that it simulates is the same as Keil uses to build the project - that is, one develops and simulates in the simulator (i.e. using VisualStudio) and then cross-compiles in Keil to generate the target code and do any additional HW debugging.


Therefore it is "compatible" with Keil, IAR, KDS, CW etc. but doesn't actually run in these IDEs as simulation.

Regards

Mark

Kinetis: µTasker Kinetis support

KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support

For the complete "out-of-the-box" Kinetis experience and faster time to market


0 Kudos