Processor Expert is a great tool: it lets me configure all the complexities of that ARM Cortex-M0+ core. But today it has fooled me and I lost several hours of my week-end time :-(. I need a user interface like push button for my project. Yes, the FRDM-KL25Z has touch area, but honestly: that kind of stuff never worked out well for me. It is probably just me having it not properly set up. The touch slider is working as in my earlier simple example, but in my other project with more hardware around it, it is working sometimes, sometimes not. Ahrg! I can blame my ignorance, my lack of understand how to configure it properly, or the extra noise by the hardware around it. Result is: I wasted a lot of time, and I give up :-(.
❗ Lesson number 1: if something is working in a small project, it does not mean that it works as well in another context.
Instead loosing more time using the TSS library, I decided to use the Reset button on the Freedom board instead. A nice feature of the KL25Z is to disable the Reset function and to use it as a general purpose I/O pin. I did this already in an earlier project, and it worked. So it should not be a big deal to have it as well in my other project?
❗ Lesson number 2: never make the assumption that if something worked in one project, it works in another.
So I added a BitIO and configured it for PTA20/RESET_b:
Next, the CPU component rightfully complains about using the Reset Pin twice:
With disabled Reset Control, Processor Expert is happy:
Generating Code, building the application, then downloading it to the board, and then I tried it out: pressing the Reset/SW1 button, and……
RESET!
Outsch. But I have configured it to *not* reset. What’s wrong?
Ok, probably my fault. Checked the settings again, generated code again, downloaded it again, and ….. RESET!
Ok, going back to my earlier project, and: here it works! Ok, so I have missed a setting?
❗ Lesson number 3: Having written a tutorial on a topic does not mean that I will be successful in that topic the next time. I need to burn my fingers once or twice first.
As comparing Processor Expert settings is not really simple, I decided to compare the generated source code.
💡 Comparing the ProcessorExpert.pe XML file is not really practical. What works in most cases is to ‘pin’ one component inspector and compare it with the other. But this is only practical for simple components. And I do not think I would have found my issue that way.
And indeed, after I while I have found that my project does not set RESET_PIN_CFG to zero in Cpu.c:
And now this was ringing a bell! And yes, indeed, I missed this other setting here where I need to disable the Reset Pin Function:
❗ Lesson number 4: Read carefully what you have written in the past. Don’t think that you just can browse through it. I had that screenshot in my earlier post, but simply missed it :-(.
Ok, now I probably will remember next time :-).
❓ That setting is buried under Flash Configuration field > Peripheral Settings. Yes, that kind of stuff is in that part of the microcontroller. But very, very easily to miss. Or should I think about ‘Reset functionality’ when I read ‘Flash configuration’? It would be really great if Processor Expert could add a ‘search’ for all fields of a component, especially the CPU component, as it has so many settings.
Ok, I learned my lessons. And maybe there is another one:
❗ Lesson number 5: Even if Processor Expert simplifies a lot of things, the cause of this are these incredible complex microcontroller today. Looks like I still need to read the several thousands of Reference Manual pages, and to read it probably several times? 😦
Now that Reset button is working as a normal user button, so I can continue my week-end project. And I hope I can prevent someone else to fall into the same trap I did.
Happy Reseting 🙂
Pingback: Processor Expert Configuration Registers View | MCU on Eclipse
Hi Erich,
“It would be really great if Processor Expert could add a ‘search’ for all fields of a component, especially the CPU component, as it has so many settings.”
If you look to the drill down menu of Component Inspctor, you can find menu “Search…” (I wander why Ctrl+F is not working for me now). It searches by the “Item name” field, also accepting wild cards.
Or did you mean other functionality?
Libor
LikeLike
Hi Libor,
It took me about 5 minutes to find what you mention here. Wow, that functionality is *really* burried, I never would have thought that that this functionality would be down that menu. But really interesting that it exists :-). Thanks for the tip, and I guess now I need to publish a tip on it, as I have heard the same thing from many users.
LikeLike
Ctrl+F works after applying the Update#1, I realized it later after sending the post.
LikeLike
Yes, I realized that myself too.
LikeLike
Pingback: Search in Processor Expert Component Properties | MCU on Eclipse
Pingback: Bricking and Recovering FRDM-KL25Z Boards: Reset, SWD Clock and Low Power | MCU on Eclipse
Pingback: Using the FRDM-KL25Z as USB Keyboard | MCU on Eclipse
Pingback: Pin Muxing: Using the NMI Pin as GPIO Pin | MCU on Eclipse
Hello Erich,
I’ve a doubt about this, altough it is the opposite of this topic.
I’m using reset pin as RESET, connected to the programmer header. I’ve been working without making initial configurations for the pin, as Processor Expert did. For example:
PORTA_PCR1 = (uint32_t)((PORTA_PCR1 & (uint32_t)~(uint32_t)(
PORT_PCR_ISF_MASK |
PORT_PCR_MUX(0x04)
)) | (uint32_t)(
PORT_PCR_MUX(0x03)
));
My code works normally. But I have experienced some unexpected resets problably due to the voltage spikes I’ve seen on the feed voltage.
My doubt is: it is really necessary to configure the reset pin to do so?Or should I let the pin “unconfigured”? PORTA_PCR shows that it is 0x00000000 from reset.
Have you ever seen this improve resets rejection?
Many thanks.
Frederico
LikeLike
Hi Frederico,
I had issues with injection spikes in one of my designs. The problem was that the external pull-up for the reset pin was not strong enough (was originally I think 10 kOhm, changed it to 1 kOhm. Additionally, the C of the RC had to be changed. More important, I was using the internal filter of the reset pin. This was for a KL25Z in a noisy environment. With above, plus enabling the internal reset filter, the system was working very well. Maybe something like this helps you too?
Erich
LikeLike
Thanks Erich,
the uC I’m using is a KL05Z, it looks like KL25Z.
So I will add the configuration for pin to select reset, input filter and pullup resistor.
Frederico.
LikeLike
Hi Erich,
I just updated from CodeWarrior to KDS3.2.0 and now it seems I can never use the reset pin for anything else but Reset (i.e. it never seems to be disabled). I have checked in the generated cpu.c and it seems the pin should be disabled, but it really isn’t:
/* NV_FOPT: ??=1,??=1,FAST_INIT=1,LPBOOT1=1,RESET_PIN_CFG=0,NMI_DIS=0,??=1,LPBOOT0=1 */
0xF3U,
Any idea what I am doing wrong? Does this project work for you on KDS?
LikeLike
Hi Ralph,
With RESET_PIN_CFG=0 the reset pin functionality is disabled, so things are correctly setup on your side. KDS does it correctly. Actually it cares now about the second step to update the flash configuration setting (RESET_PIN_CFG=0). I just tried it with KDS v3.2.0 (should be the same with KDS V3.0.0) and it works for me as expected.
I hope this helps,
Erich
LikeLike
Hi Erich,
thanks for the answer. It turns out the problem actually was in the firmware, which I had programmed onto the FRDM-KL25Z board, which would transfer the code, but not set the reset pin correctly. I am now using the PE-micro one and it works fine.
Thanks,
Ralph
LikeLike
Has Processor Expert changed since the time of this post to remove this flash configuration field settings? I just installed KDS and created a test application for the FRDM-K64F and I am getting an NMI interrupt no matter what I do. I haven’t connected the PTA4 pin to anything. NMI pin is disabled.
LikeLike
No, things have not changed to my knowledge. One thing to keep in mind is that this post changes the muxing (routing the push button to the NMI input logic). The NMI itself is non-maskable, so if your application still triggers a NMI interrupt for whatever reason, the NMI interrupt will happen.
LikeLike
I understand that, it’s just that the setting is there in the GUI option for Changing LPBOOT and EZPORT_DIS, but not NMI_DIS. The funny thing is, the generated file CPU_Config.h has the bit set to high, which enables NMI. In my last PE installation (KDS) this option was there under Peripheral settings. Now it’s called common settings and NMI is hard corded to always on. I am changing the generated file to test. If it works I will disabled generating code for the CPU.
LikeLike
I think it depends on the board or if it is a K series or a KL series. For KL25Z the setting is under Internal peripherals and for K64F it is under common settings.
LikeLike
I am sending you a screenshot on email just so you can see what am seeing on the UI
LikeLike
The problem is I had a shell component without a default serial child component set, so when I try to send something on it, it was causing an NMI interrupt. I fixed that.
LikeLike
Hmm, I think this actually should result in a hard fault, not in the NMI itself. Have you added a hard fault handler to your project? https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/ and https://mcuoneclipse.com/2012/12/28/a-processor-expert-component-to-help-with-hard-faults/
LikeLike
No, I had not done that, but I had enabled the option for o
LikeLike
No but I had enabled the CPU option own handler for every unhandled vector, it didn’t go to hard fault, went straight to NMI. I will check this now.
LikeLike
Pingback: Recovering Cortex-M Microcontroller with a Power Glitch | MCU on Eclipse