
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is a probles about Kinetis K10 MCU.
Usually when I want to configure a pin as the funcion I require,I need only call the following macro definition:
#define IO_FUN_SEL(PTO, BIT, FUN) \
PCR(PTO,BIT) = (PCR(PTO,BIT) & (~PORT_PCR_MUX_MASK))|PORT_PCR_MUX(FUN)
In this macro definition,the parameter FUN stands for the number sequence of function option and can be 0~7(stands for ALT0~ALT7),refer to the table below:
For example,if I want to configure the Pin PTC0(the 43rd pin) as the SPI0_PCS4,I need just define FUN as 2,namely the related code is:PORT_PCR_MUX(2).
Now please look at the Pin PTC2,there are 3 items(ADC0_SE4b,CMP1_IN0,TSI0_CH15) in the unit ALT0.
1) So which funciton is really actived if I define the FUN as 0(PORT_PCR_MUX(0)) ?
2) And ,if I want to configure the pin as the function wanted,what's the code?
Actually,I think that there are some other factors affecting the selection of pin function,but I can't find them.Who can tell me?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In this cases these pins have multiple assignments in the same ALT configuration. The pin is configured in PCR register as 0 in MUX field: PORT_PCR_MUX(0) but after this in each module you need to select this configuration. I will use the PTC2 pin in order to explain this:
- PORTC_PCR2 = PORT_PCR_MUX(0); //Enable ALT0 for portC2
- If you want to use PTC2 as ADC0_SE4b you need to refer to ADCx registers, e.g:
ADC0_CFG2 = ADC_CFG2_MUXSEL_MASK; //All ADxxb channels are selected
- If you want to use PTC2 as CMP1_IN0 you need to refer to CMPx_MUXCR register, e.g:
CMP1_MUXCR = CMP_MUXCR_PSTM_MASK //Pass Through Mode Eable enable, PTM is used
//to enable to MUX pass through mode
Then you need to choose between PSEL or MSEL fields, the Plus and Minus inputs respectively.
- If you want to use PTC2 as TSI0_CH15 you need to refer to TSIx_PEN register, e.g:
TSI0_PEN = TSI_PEN_PEN15_MASK; //The corresponding pin is used by TSI
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In this cases these pins have multiple assignments in the same ALT configuration. The pin is configured in PCR register as 0 in MUX field: PORT_PCR_MUX(0) but after this in each module you need to select this configuration. I will use the PTC2 pin in order to explain this:
- PORTC_PCR2 = PORT_PCR_MUX(0); //Enable ALT0 for portC2
- If you want to use PTC2 as ADC0_SE4b you need to refer to ADCx registers, e.g:
ADC0_CFG2 = ADC_CFG2_MUXSEL_MASK; //All ADxxb channels are selected
- If you want to use PTC2 as CMP1_IN0 you need to refer to CMPx_MUXCR register, e.g:
CMP1_MUXCR = CMP_MUXCR_PSTM_MASK //Pass Through Mode Eable enable, PTM is used
//to enable to MUX pass through mode
Then you need to choose between PSEL or MSEL fields, the Plus and Minus inputs respectively.
- If you want to use PTC2 as TSI0_CH15 you need to refer to TSIx_PEN register, e.g:
TSI0_PEN = TSI_PEN_PEN15_MASK; //The corresponding pin is used by TSI
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks a lot!:smileyhappy:
