With the NXP Pins Tool (see “Tutorial: Muxing with the New NXP Pins Tool“) I can configure and mux (multiplex) the microcontroller pins. What is really powerful and what might not be so obvious at the first sight is that it gives me deep control over every register bit and setting. For example I have below the PTB1 (Port B, pin 1) muxed as GPIO (General Purpose I/O):
But it only generates this:
void BOARD_InitPins(void) { CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */ PORT_SetPinMux(PORTB, PIN1_IDX, kPORT_MuxAsGpio); /* PORTB1 (pin 54) is configured as PTB1 */ }
So what about all the other bits and pieces?
Clock Gates
The first line turns on the clock gates (clocks the peripheral, otherwise any access to the peripheral will create a hard fault):
CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */
If I do that myself in my application, I can configure this with the Properties menu:
Which provides a setting for this:
Init or not init, that’s the question
The other thing is the code it generates for the muxing:
PORT_SetPinMux(PORTB, PIN1_IDX, kPORT_MuxAsGpio); /* PORTB1 (pin 54) is configured as PTB1 */
It ‘only’ configures the muxing, but what about all the other settings, like direction, slew rate and so on?
The thing is that the tool is using/assuming ‘out-of-power-on/reset’ values. So the code is optimized for that case. But there are cases where I would like to do a ‘full’ initialization, e.g. because I need to re-configure the hardware based on different reset (like a software reset), or because some safety rules require me to do a full initialization.
The visual cue is that the values in italic font show me which values are implicitly set, and which ones are explicitly configured by me. Such as in the hardware the slew rate is set to ‘fast’ by default:
I can explicitly set the slew rate to Fast:
Now it is explicitly set to fast (not in italic)
And with this I get the slew rate explicitly set:
void BOARD_InitPins(void) { CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */ PORT_SetPinMux(PORTB, PIN1_IDX, kPORT_MuxAsGpio); /* PORTB1 (pin 54) is configured as PTB1 */ PORTB->PCR[1] = ((PORTB->PCR[1] & (~(PORT_PCR_SRE_MASK | PORT_PCR_ISF_MASK))) /* Mask bits to zero which are setting */ | PORT_PCR_SRE(PCR_SRE_FAST) /* Slew Rate Enable: Fast slew rate is configured on the corresponding pin, if the pin is configured as a digital output. */ ); }
If I want to explicitly set it to ‘do not initialize’, there is a menu item for this too:
Then this bit and setting does not get configured.
Summary
If I need the clock gates turned on or not, depends on the application. As for myself, I prefer to have it initialized by the Pins tool. If I do it in the application code, there is a setting for it to turn it off.
By default, the tool only initialize the bits and registers needed, coming out of reset. The values in italic are not configured as already in that state. If I want to explicitly initialize such a setting, I can configure it to be initialized. In that case, the setting turns from ‘italic’ to ‘non-italic.
💡 The above is actually really powerful: I can use the ‘tabs’ or ‘functions’ to create initialization code depending on my needs. But that would be probably
Happy Biting 🙂
Links
- NXP Pins Tool (online version): http://kex.nxp.com/
- Tutorial using the Pins Tool: Muxing with the New NXP Pins Tool
Hi Eric, I have started using the Pins tool on 3 different processors, its a good time saver and also helps with checking hardware designs – pin assignments prior to board release. Previously I was extracting the Pin assignments table from the datasheets and creating my own excel spreadsheets to document and map pin assignments. I have encountered an issue when creating new configurations that occurs after the application is used for some time, it pops up a message box that says “Cannot download the Processor Database”. If I uninstall and reinstall the application the issue is resolved and I can create new processor configurations. I searched the NXP community but it seems nobody has encountered this issue.
LikeLike
Hi Chad,
the processor database only gets downloaded once (for the desktop tool) when you create a new configuration. I think I should post a article where that data is located on disk?
Additionally it checks the data on the server at startup to download updates (which can be turned off).
But I think what you saw was that the NXP servers seemed to be down yesterday and/or the day before (maybe because of Pokemon Go? 😉 )
LikeLike
Yes probably the Pokemon unless Super Mario Go – freeway edition has just been released! Actually the issue resolved just now when I reinstalled it. There was a 5 min window between it not working and when it finished reinstalling and I tried it again with success. For now I have a workaround, so no problem 🙂
LikeLike
Pingback: NXP Pins Tool: Understanding Data for Offline Usage | MCU on Eclipse
Pingback: Investigating ARM Cortex® M33 core with TrustZone® – Using the Pins Config Tool | MCU on Eclipse