K60F120M flashing

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

K60F120M flashing

683 Views
chandu_nav
Contributor I

I have successfully flashed an LED blinking application on TWR K60F120M board but when I run the application the execution is unstoppable its going to some unknown memory I have flashed my code into flash address 0x00000000

Below is I have copied my code

#include "twr-k60f120m.h"
#include "mcg.h"
#include "cw.h"
#include "MK60F12.h"
void wait (void);


const int led_user1 = ((unsigned int) 0x01 << 11);
const int led_user2 = ((unsigned int) 0x01 << 28);
const int led_user3 = ((unsigned int) 0x01 << 29);
const int led_user4 = ((unsigned int) 0x01 << 10);

#define GPIO_PIN(x) (((1)<<(x & GPIO_PIN_MASK)))
#define GPIO_PIN_MASK 0x1Fu

void wait (void)
{
int i;
for(i=0;i<500000;i++);
}

int main (void)
{
//Set PTA10, PTA11, PTA28, and PTA29 (connected to LED's) for GPIO functionality
PORTA_PCR10=(0|PORT_PCR_MUX(1));
PORTA_PCR11=(0|PORT_PCR_MUX(1));
PORTA_PCR28=(0|PORT_PCR_MUX(1));
PORTA_PCR29=(0|PORT_PCR_MUX(1));


//Change PTA10, PTA11, PTA28, PTA29 to outputs
GPIOA_PDDR=GPIO_PDDR_PDD(GPIO_PIN(10) | GPIO_PIN(11) | GPIO_PIN(28) | GPIO_PIN(29));

for(;;)

{

//Set PTA10 to 0 (turns on blue LED)
GPIOA_PDOR&=~GPIO_PDOR_PDO(GPIO_PIN(10));
wait();
//Toggle the green LED on PTA29
GPIOA_PTOR|=GPIO_PDOR_PDO(GPIO_PIN(29));
wait();
//Set PTA28 to 0 (turns on yellow LED)
GPIOA_PDOR&=~GPIO_PDOR_PDO(GPIO_PIN(28));
wait();
//Set PTA11 to 0 (turns on orange LED)
GPIOA_PDOR&=~GPIO_PIN(11);
wait();

/* GPIOA_PCOR = led_user1;
- wait();
- GPIOA_PCOR = led_user2;
- wait();
- GPIOA_PCOR = led_user3;
- wait();
- GPIOA_PCOR = led_user4;
- wait();
-
- GPIOA_PDDR = led_user4;
- wait();
- GPIOA_PDDR = led_user3;
- wait();
- GPIOA_PDDR = led_user2;
- wait();
- GPIOA_PDDR = led_user1;
- wait();*/

}

}

Labels (1)
4 Replies

550 Views
mjbcswitzerland
Specialist V

Hi Naveen

Probably you have missed enabling clocks to the port and so it will hard faut when you try to use them.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K60:
- http://www.utasker.com/kinetis/TWR-K60N512.html
- http://www.utasker.com/kinetis/TWR-K60D100M.html
- http://www.utasker.com/kinetis/TWR-K60F120M.html
- http://www.utasker.com/kinetis/ELZET80_NET-KBED.html
- http://www.utasker.com/kinetis/ELZET80_NET-K60.html

K60 some first steps for beginners to Kinetis: http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M


For better, faster, cheaper product developments consider uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

550 Views
chandu_nav
Contributor I

Hi Mark, 

Thanks a lot for your reply, 

Could you please help me with enabling the clock for PORT A for your information I am not working with either IAR or CodeWarrior IDEs. The above given is my actual code please help me with enabling clock for PORT A. 

Thanks in advance. 

0 Kudos

550 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi  Naveen,

You can refer the gpio example in KINETIS_120MHZ_SC.

enable clock gate.PNG

Best Regards,

Robin

 

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

0 Kudos

550 Views
mjbcswitzerland
Specialist V

Naveen

Set PORTA flag in SIM_SCGC5.

Or download the project in the link and start working with Ethernet, USB, SD card, etc. within 15 minutes (in CW and IAR).

Regards

Mark

0 Kudos