HOW CAN I ACCESS PORT PIN IN FREESCALE,in my code i need to access porte pin17 ,

cancel
Showing results for 
Search instead for 
Did you mean: 

HOW CAN I ACCESS PORT PIN IN FREESCALE,in my code i need to access porte pin17 ,

851 Views
Contributor II

#define data gpio_pdor<<17 is not working ,can any body know other method

8 Replies

4 Views
NXP Employee
NXP Employee

Hi sreenath,


please, what do you want to exactly do with the macro?

Access to read, write, toggle??

Thank you,

Best Regards,

Iva

0 Kudos

4 Views
Contributor II

i need to read and write to the port pin .

0 Kudos

4 Views
Senior Contributor I

You didn't mention what part you're using so I don't know which physical pin you're trying to control, but as an example:

GPIOA_PDDR |= (1 << 17) //makes the pin an output by setting bit 17 of the data direction register

GPIOA_PDOR |= (1 << 17) //drives bit 17 high

GPIOA_PDOR &= ~(1 << 17) drives bit 17 low

If you're using it as an input:

GPIOA_PIDR &= ~(1 << 17) //enables input

if(GPIOA_PDIR & (1 << 17))

{    

     /*do something if bit 17 is high

}

4 Views
Senior Contributor III

Is PortE within GPIOA on the processor in question?

0 Kudos

4 Views
NXP Employee
NXP Employee

Earl,

small error. Just replace port A to port E.

So:

GPIOE_PDDR |= (1 << 17) //makes the pin an output by setting bit 17 of the data direction register

GPIOE_PDOR |= (1 << 17) //drives bit 17 high

GPIOE_PDOR &= ~(1 << 17) drives bit 17 low

If you're using it as an input:

GPIOE_PIDR &= ~(1 << 17) //enables input

if(GPIOE_PDIR & (1 << 17))

{  

    /*do something if bit 17 is high

}

Best Regards,

Iva

0 Kudos

4 Views
Senior Contributor III

I only asked because I found out in the last question(!) that some Kinetis parts renamed port access so that 8-bit-ports DBCA are in GPIOA, HGFE in GPIOB (etc.).  The original request actually mentions PIN 17 (on some unspecified package), and maybe that is what they meant, not Bit 17 (although the <<17 led us all to that belief!).

0 Kudos

4 Views
NXP Employee
NXP Employee

Hello Earl,

yes, you probably think this article. There is difference for KE family.

KEA128 BIT access

You can also find it useful the thread about blinking LED for K40

K40: Blink LED

But sreenathreddy does not tell us what MCU is using.

Best Regards,
Iva

0 Kudos

4 Views
NXP Employee
NXP Employee

Yes, definitely correct.

Best Regards,

Iva

0 Kudos