KL25Z GPIO simulation (Keil)

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

KL25Z GPIO simulation (Keil)

ソリューションへジャンプ
2,917件の閲覧回数
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)

タグ(4)
1 解決策
2,076件の閲覧回数
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 件の賞賛
返信
5 返答(返信)
2,076件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

2,076件の閲覧回数
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 件の賞賛
返信
2,076件の閲覧回数
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

2,076件の閲覧回数
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 件の賞賛
返信
2,077件の閲覧回数
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 件の賞賛
返信