9 years, 3 months ago.

High Drive mode in FRDMKL25Z

How to use high drive mode in FRDMKL25Z. The datasheet says that the register PTx_PCRn has to be configured to obtain the high drive capability. Please help me out with configuring the registers.

1 Answer

9 years, 3 months ago.

Dear Santosh-san,

I tried to find PORTx_PCRn in mbed source, but could not find one.
So, in the Reference Manual of KL25Z, 11.5 memory map and register definition
there is a list of address(es) of these ports.
For example if we use D4, which is PTD4 of KL25Z,
the register would be PORTD_PCR4 which is 4004_C010 according to the list.
The drive strength bit is DSE which is bit 6 of PORTx_PCRn, so it is 0x40

So if you say

#include "mbed.h" 

DigitalOut dout(PTD4) ; 

int main() {
uint32_t *PORTD_PCR4 = (uint32_t*)0x4004C010 ; 

 *PORTD_PCR4 &= ~0x40 ; /* low drive strength */ 
 *PORTD_PCR4 |= 0x40 ;  /* high drive strength */ 

/* do whatever you like to */ 
}

Please note that this is what I "think" work, but I have not tested it.

moto

Accepted Answer

All those registers are included in the CMSIS files, no need to define the address manually. Here is the relevant file: http://developer.mbed.org/users/mbed_official/code/mbed-src/file/e03396e14338/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/MKL25Z4.h

From there it should be addressable as:

PORTD->PCR[4]
posted by Erik - 03 Feb 2015

Wow, that file is very helpful!
Then we can say

PORTD->PCR[4] |= PORT_PCR_DSE_MASK ; 

moto

posted by Motoo Tanaka 03 Feb 2015

Correct :). They are defined by the manufacturer, so what they define exactly differs a bit (as you found out, Freescale also defines bit masks, not all have them), but in principle it makes it alot easier to use those.

posted by Erik - 04 Feb 2015

Thanks for the reply. It is working for me.

posted by Santosh Kulkarni 04 Feb 2015