9S12 Configuring PMF's and Port P inputs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

9S12 Configuring PMF's and Port P inputs

953 Views
JamesonB
Contributor I

Hello, 

 

I am using an MC9S12E128 in which the PMF module is on the P port. I am trying to enable only PMF4 and 5 on Port P while using PP0-PP3 as inputs. I'm aware that a peripheral takes prescidence over its corresponding Port I/O statements, however there is a line in the datasheet that states:

 

"The PMF function takes precedence over the general-purpose I/O function if the associated PWM channel

is enabled. The PWM channels 5-0 are outputs if the respective channels are enabled."

 

The Datasheet seems a little foggy on how to disable PMF channels and use them as inputs. Here is a snippet of my initialization code: 

 

void Init_PMF(void)

{

PMFCFG0=0x5F; //Each pair of PMF's uses a different time base. A and B are edge aligned
// C is Center Aligned & are independent
PMFCFG1=0; //Positive polarity
PMFCFG2=0; //Unmasked
PMFCFG3=0; //PMF's run in 'Wait & Freeze' modes, No pair swapping
PMFOUTC=0x0F; //Enable software control of PWM pin
PMFOUTB=0x30; //disable PWM0-3

PMFENCC=0; //Verify that timer C for PMF4 & 5 is disabled
x=PMFENCC; //Read register prior to writing a 1 to the LDOKC bit
PMFENCC=2; //Write a 1 to the LDOKC bit

 

DDRP=0x30;  //Enable PT0-3 as inputs, PT4 and 5 are PWM

}

 

I'm sure there is are quite a few 9S12 Guru's out there who have encountered this before or have some words of wisdom. I prefer to use the configuration mentioned above due to an existing PCB layout.  

 

What is the proper way to configure the PMF3 and PMF4 peripheral and PT0-3 as Input pins?

 

Thanks, 

Jameson

Labels (1)
0 Kudos
2 Replies

729 Views
JamesonB
Contributor I

Well....I've figured it out. the key: Don't use device initialization like I was. For some reason, device initialization was trying to set up all of the PMF modules when I only needed Module C (i.e. PMF 4 and 5). 

 

Thanks to anyone who looked into this. If anyone is interested in the solution, just request it. 

0 Kudos

569 Views
ovek
Contributor I

I am trying to get all 6 PWM to work independently  on a s12e on the PMF port P. Whithout any PMF-functionality activated. The PMF-init example I found didn't seem to work so any source-code example that you have about this PMF-module would be a help.

Best regards

 

0 Kudos