KL03Z Minimum Program (LED Blink)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

KL03Z Minimum Program (LED Blink)

1,574 次查看
dsam1
Contributor I

Hi all, 2 problems I'm having:

I have a MKL03Z8VFG4 that I soldered to a QFN16 breakout board. I plugged this into a breadboard. I put a decoupling cap between VCC and GND (and connect a linearly regulated 3.3V to it), put a pullup resistor on NMI_b, and put a pulldown button closer to the NMI_b pin so I can enter bootloader mode. I also connect a USB to 3.3V UART adapter's TX, RX, and GND to the board. This works for a while.

1. I rarely move stuff around on my desk, and I'm being very careful not to generate static (everything is grounded back to my metal case laptop), but eventually (a few hours to a few weeks) the chip will stop responding. The chip didn't pop or even get hot as far as I can tell. But when holding the button to put it in bootloader mode, then using the KinetisFlashTool to 'connect' to the bootloader, it will not respond. I don't think anything is running, since on the chip's TX pin I can see the cross-talk noise (a few millivolts on the adapter's RX) from my USB UART adapter's TX signal (they happen synchronously, I checked with a scope). Is there any other way to see if my chip is still alive?

2. I've been having a hell of a time getting the minimum program working, while the chip is still alive. See code below. I'm just trying to blink an LED! (rather, toggle an output... I just use my scope and probe the pin in case the chip can't support the 1 mA of LED current.)

#include "system_MKL03Z4.h"

#include "MKL03Z4.h"

int main(){

   

    SystemInit();

    PORTA_PCR1 = 0x143;        // port A pin 1 is gpio (bit 8 set), drive strength high (bit 6 set)

    GPIOA_PDDR = 0x2;            // port A pin 1 is output (bit 1 set)

    GPIOA_PSOR = 0x2;            // port A pin 1 set high (bit 1 set)

    //SIM_SCGC5 = 0x200;        // already set in system_MKL03Z4.c --- port A clock enable (bit 9 set)

   

    int i;

    while(1){

        for (i=0; i>40000; i++){

            GPIOA_PTOR = 0x2;        // port A pin 1 toggle

        }

    }

   

    return(0);

}

BTW I'm using Keil uVision because the aliases in KDS were giving me a headache. Keil is much easier to read IMO.

Thanks in advance for any help!

标签 (1)
0 项奖励
回复
6 回复数

1,203 次查看
dsam1
Contributor I

Kind of solved it.

One issue is that I think I was killing chips. These things are more sensitive than I'm used to!

Second is that for some of the time, I had reset attached to an LED, which didn't let the chip reset and therefore connect to the bootloader. Once I fixed this, some chips came back alive and some didn't.

Thank you NXP for helping me debug.

0 项奖励
回复

1,203 次查看
dsam1
Contributor I

Jingjing and Jay, thank you for your help!

I will investigate the reconfiguring of the reset pin next. For now I switched the LED to PortA7.

I borrowed a PE Micro Multilink Universal and hooked up to the SWD pins, it seems like the chip is still alive, since when I hit the "Download (F8)" button, it says "Flash Load Finished" (though I don't see any proof, PTA7 still does not toggle, even after power cycle). Does programming with the Multilink Universal actually verify the flashed program or does it only push data one direction?

I am also confused about the bootloader. When I boot the chip with NMI_b held low, it should enter the bootloader, yes? Then I should be able to use KinetisFlashTool and my USB serial port cable (3.3v) to 'connect' to the chip. I still can't do this, even after flashing a file that sets PTB1/2 as TX/RX, over SWD.

I'm swapping out a few of the chips today in case the chips are actually broken.

Thank you!

0 项奖励
回复

1,203 次查看
jay_heng
NXP Employee
NXP Employee

Hi Daniel,

Please check the value of offset 0x40d in your LED image (.bin format) to see whether it is equal to 0x3D (For detail , please refer to 27.3.1 Flash Configuration Field Description and 6.3.2 FOPT boot options in KL03 RM), this value will be loaded into FTFA_FOPT register automatically after reset.

  the value 0xFF, 0xFD means device will always boot from ROM (0x1c00_0000)

  the value 0x3F means device will always boot from FLASH (0x0000_0000)

  the value 0x3D means device will boot from ROM if BOOTCFG0 pin (NMI) asserted, otherwise, device will boot from FLASH. Note: NMI pin is sampled at the end of reset (when reset pin negates).

Best Regards,

Jay

0 项奖励
回复

1,203 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Daniel,

  1. If you have the JLINK, you can use JLINK commander to check it, if the JLINK commander can find the core through SWD interface, your chip is still alive.

2. PTA1 is the reset pin, it is in default as RESET_B function, you can't change it by the PORT mux directly, I suggest you choose other pin as the LED output pin, eg, PTA5.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Jingjing

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

0 项奖励
回复

1,203 次查看
dsam1
Contributor I

Jingjing,

Thanks for your help. I don't have a JLINK device so I guess I'm stuck there.

I'm still confused about the IO. I included the line PORTA_PCR1 = 0x143; to convert PTA1 to a GPIO. Did I select the wrong bits? According to the reference manual, this is how GPIO function is selected on Port A Pin 1.

0x143 works out to setting bits 8, 6, 1, and 0.

Capture.PNGCapture2.PNGCapture3.PNG

0 项奖励
回复

1,203 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Daniel,

    PTA1 is the special pin, it is in default as RESET_b function:

64.jpg

    If you want to disable the reset function , you should modify the FOPT register, this register data is put in flash Address 0x40d

65.jpg

66.jpg

So, if your pins are enough to use, I suggest you use other pin as the GPIO pin, don't choose SWD pin, NMI, RESET pin.

Wish it helps you!

If you still have question, please contact me!


Have a great day,

Jingjing

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

0 项奖励
回复