Hello world program for Kinetis

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

Hello world program for Kinetis

ソリューションへジャンプ
4,506件の閲覧回数
FabianS
Contributor II

Hello,

 

I am trying to write a small hello world program for the Kinetis K60 but it's not working. It's just a pin I want to toggle.

[code]

#include <stdio.h>

#include "derivative.h" /* include peripheral declarations */

int main()
{
    //MCU_init();
    
    GPIOC_POER |= (1<<0);
    while(1)
    {
        printf("Hello World!\n");
        GPIOC_PTOR = (1<<0);
    }
    return 0;
}
[/code]

Using MCU_init or not makes no difference. The pin simply does nothing.

I also tryed to use a DAC but when I add the DAC0 settings in the "Target CPU" view the program crashes and jumps to PE_ISR(isrINT_NMI) when calling the MCU_init method.

 

PS: Why is here no extra forum for Kinetis?

0 件の賞賛
1 解決策
2,074件の閲覧回数
MikeRC
Contributor III

Try this for the main function:

 

int main()
{
    //MCU_init();
    

    SIM_SCGC5 = 0x800;

    PORTC_PCR0 = 0x00000100;


    GPIOC_POER |= (1<<0);
    while(1)
    {
        printf("Hello World!\n");
        GPIOC_PTOR = (1<<0);
    }
    return 0;
}

 

The GPIO is a lot different for Kinetis than it used to be for Star 12's.  The PortC clock needs to be enabled and the Pin Mux needs to be set to use the GPIO functionality.

-Mike

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
2,075件の閲覧回数
MikeRC
Contributor III

Try this for the main function:

 

int main()
{
    //MCU_init();
    

    SIM_SCGC5 = 0x800;

    PORTC_PCR0 = 0x00000100;


    GPIOC_POER |= (1<<0);
    while(1)
    {
        printf("Hello World!\n");
        GPIOC_PTOR = (1<<0);
    }
    return 0;
}

 

The GPIO is a lot different for Kinetis than it used to be for Star 12's.  The PortC clock needs to be enabled and the Pin Mux needs to be set to use the GPIO functionality.

-Mike

0 件の賞賛
2,074件の閲覧回数
anthony_huereca
NXP Employee
NXP Employee

You can also look at the GPIO example in the Kinetis Sample Code for more examples of blinking the LED's: http://www.freescale.com/webapp/sps/download/license.jsp?colCode=KINETIS512_SC