explanation needed for port module in MC9S12ZVC family controller

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

explanation needed for port module in MC9S12ZVC family controller

4,999件の閲覧回数
sathishkannan
Contributor III

1) I am facing trouble to set pins as input and enable interrupt for input pin in PAD register.kindly help me with a sample code

 

2)how to set register for taking input in ad port as digital input.

 

3)I am not possible to set output pin for PSO pin in MCUsS12ZVC Evaluation Board.its showing 3v constant after setting output and data direction register.not change according to data register status.

ラベル(1)
タグ(4)
0 件の賞賛
返信
13 返答(返信)

4,596件の閲覧回数
sathishkannan
Contributor III

Suppose i am using PAD7 .its showing that it will act as GPIO after reset.When it become analog pins,Is it at the time of adc configuration ?if yes explain,or any particular register for changing the functionality of pins ?

0 件の賞賛
返信

4,596件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Sathish,

About PAD7)

Please look at Table 2-2. Pin Functions and Priorities in RM.

If there is more than one function associated with a pin, the output priority is indicated by the position in the table from top (highest priority) to bottom (lowest priority).

So, until we enable DAC or ADC module for this pin, pin could be used as GPIO pin. With exception that by default digital input buffer is disabled after reset – See DIENAD register.

When DAC is not enabled, ADC module could be used for measuring voltage at PAD7 pin.

In fact, GPIO state at PAD7 will be not affected by either enabling ADC (reading appropriate channel) or by enabling DAC module. See Table 2-34. Effect of Enabled Features in RM.

So, PAD7 is configured as analog pin until you enable digital buffer (DIENAD, after that it will be digital pin) or until you switch this pin into output mode (DDRAD). Of course, PAD7 will work as analog pin only when you configure ADC module and start appropriate conversion. No modifications in pin registers are needed for measuring analog voltage at port AD.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

4,597件の閲覧回数
sathishkannan
Contributor III

thanks for your answer.

I need much more clarification regarding port.

With reference to table 2.2 .i found muliple functions in a single pin.how to enable each functionality.

for eg PAD5/KWAD5/AN5/ACMPOI.

2) what all the default nature of all port pins ?is it GPIO.if not please explain default nature of each port pins.

3)why module routing register used ?

4)ADC port pins are analog by default or not ?

0 件の賞賛
返信

4,597件の閲覧回数
ankur_kala
NXP Employee
NXP Employee

Hi Sathish,

Please find the replies below:

2) what all the default nature of all port pins ?is it GPIO.if not please explain default nature of each port pins.

[AK] Section 2.2 External Signal Description in the RM describes the pin functionalities and their state after reset. Its difficult to write everything here but for your eg. of PAD5/KWAD5/AN5/ACMPOI, pin function after reset is GPIO (Most of the pins have GPIO as the defulat functionality after reset).

3)why module routing register used ?

[AK] Module routing registers are used to assign pins to IP modules. For eg. Module routing register 0 can be used to define which pins get associated with SCI1, SCI0 and SPI0. Please refer to section 2.3.2 in the RM.

4)ADC port pins are analog by default or not ?

[AK] Most analog pins default state after reset is GPIO as mentioned in Section 2.2 of the RM.

Regards,

Ankur

2) what all the default nature of all port pins ?is it GPIO.if not please explain default nature of each port pins.

3)why module routing register used ?

4)ADC port pins are analog by default or not ?

0 件の賞賛
返信

4,597件の閲覧回数
ankur_kala
NXP Employee
NXP Employee

Hi Sathish,

have you tried using the Processor Expert tool. You can graphically set the PAD as input. Please see the figure attached. Once done, you can look for the function ' PE_low_level_init();' in main.c file. this function consists of all the peripheral definitions configured through Processor Expert.

4,597件の閲覧回数
sathishkannan
Contributor III

where to read inputs from port pins.

how to configure analog pins in port adl as input pins.can u explain what all registers have to be set for taking inputs and enable interrupt for that input pin in ADL port.

thanks

0 件の賞賛
返信

4,597件の閲覧回数
ankur_kala
NXP Employee
NXP Employee

Hi Sathish,

You can read the value from port data register PTADH/PTADL. For the analog pins do you want to configure them as analog inputs or digital inputs. For configuring as digital inputs you need to follow the same steps in Processor expert as defined above. Just choose the correct pin in the pin option.

Regards,

Ankur

0 件の賞賛
返信

4,597件の閲覧回数
sathishkannan
Contributor III

sorry i am not familiar with processor expert.I am configuring registers in my code only.

1) right now i am setting DIGITAL INPUT ENABLE REGISTER for ADL and ADH port pins and reading pin status from PORT AD INPUT REGISTER.Is this the correct procedure ?if wrong means correct me and explain step wise manner.

2)Please mention the corresponding interrupt register for input interrupt register.

0 件の賞賛
返信

4,597件の閲覧回数
ankur_kala
NXP Employee
NXP Employee

Hello Sathish,

You need to include the below lines in your code for initializing pin PAD0_KWAD0_AN0_ACMP0_0

  PIFAD = 0x01U;                        /* Clear flag */

  DIENADL_DIENADL0 = 1U;               /* Enable digital input */

  PIEAD_PIEADL0 = 1U;                  /* Enable interrupt */

  __EI();                              /* Enable interrupts */

For reading the input, you can check the register PTADL ((PTADL & 0x01U) - For PAD0).

You also need to define an ISR and clear the flag in PIFAD register. The ISR also needs to be defined in the vector table at interrupt number 0x3D and address 0x00FFFEF4.

Regards,

Ankur

0 件の賞賛
返信

4,597件の閲覧回数
sathishkannan
Contributor III

Hi,

1) why digital input buffer register is provided.can we read data from digital input buffer register.

0 件の賞賛
返信

4,597件の閲覧回数
ankur_kala
NXP Employee
NXP Employee

Hello Sathish,

there is no input buffer register as such but yes for using I/O as digital input you need to enable the digital buffer (hardware) of the pin. Please go through the AN2434 (http://www.freescale.com/files/microcontrollers/doc/app_note/AN2434.pdf ) for more details.

Regards,

Ankur

0 件の賞賛
返信

4,597件の閲覧回数
sathishkannan
Contributor III

Hi,

can you provide me a sample code explaining about isr routine for input interrupt register.

0 件の賞賛
返信

4,597件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi sathish,

for example:

interrupt void PORTAD_ISR(void);  /* vector number is assigned in prm file (VECTOR 66 PORTAD_ISR)   */

interrupt void PORTAD_ISR(void)

{             

                if (PIFAD_PIFADL0)

                                {

                                PIFAD = 0x01U;                   /* Clear port AD flag */

                                //your code

                                }

}

void main(void) {

DDRAD = 0x00;                     /* set pins as input */

PPSADL = 0x00;                    /* set pull-up polarity, falling edge selected*/

PERADL = 0x01;                    /* enable pull-up on PAD0*/

DIENADL = 0x01U;                 /* Enable digital input on PAD0 pin*/

PIFAD = 0x01U;                      /* Clear port AD flag */

PIEAD = 0x01U;                      /* Enable interrupt from PAD0 pin*/

EnableInterrupts;

//...


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信