CONFIG XPIN

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = Configures all other features of a Xmega port or port pin like for example pullup but not the data direction. You still need to use&...")
 
 
Line 1: Line 1:
 
= <span class="f_Header">Action</span> =
 
= <span class="f_Header">Action</span> =
  
Configures all other features of a Xmega port or port pin like for example pullup but not the data direction.
+
Configures additional features of a processor port or pin.
  
You still need to use&nbsp;<span style="font-size: 12pt; font-family: 'Times New Roman';">PORTx = state or PINx.y = state to configure the data direction of that port or pin in addition to CONFIG XPIN.</span>
+
<span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 10: Line 10:
  
 
= <span class="f_Header">Syntax</span> =
 
= <span class="f_Header">Syntax</span> =
 +
 +
<span style="font-weight: bold; color: rgb(0, 0, 128);">CONFIG XPIN=</span>PORT|PIN, OUTPULL=pull
 +
 +
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
= <span class="f_Header">Syntax Xmega</span> =
  
 
<span style="font-weight: bold; color: rgb(0, 0, 128);">CONFIG XPIN=</span>PORT|PIN, INVERTIO=invio, SLEWRATE=slew, OUTPULL=pull, SENSE=sense
 
<span style="font-weight: bold; color: rgb(0, 0, 128);">CONFIG XPIN=</span>PORT|PIN, INVERTIO=invio, SLEWRATE=slew, OUTPULL=pull, SENSE=sense
Line 20: Line 28:
  
 
Normal AVR port pins can be configured as an input or output. When configured as an input (CONFIG PIN=INPUT) they can also be set to tri-state (write a 0 to the PORT register) or to activate the pull up resistor(write a 1 to the PORT register).
 
Normal AVR port pins can be configured as an input or output. When configured as an input (CONFIG PIN=INPUT) they can also be set to tri-state (write a 0 to the PORT register) or to activate the pull up resistor(write a 1 to the PORT register).
 +
 +
Some new AVR processors use a special PUD register to control the pull up. The CONFIG XPIN automatically uses the proper registers to control the pull up state.
 +
 +
&nbsp;
 +
 +
&nbsp;
 +
 +
= <span class="f_Header">Normal AVR</span> =
 +
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 +
{| width="609" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 +
|- style="vertical-align: top;"
 +
| valign="top" width="15%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" |
 +
PORT
 +
 +
PIN
 +
 +
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |
 +
The pin to be configured. For example PORTC.0
 +
 +
When configuring the whole port (all the pins must have the same functionality), use PORT. For example : PORTD
 +
 +
|- style="vertical-align: top;"
 +
| valign="top" width="15%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" |
 +
OUTPULL
 +
 +
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |
 +
Sets the output or pull mode. The following options are available:
 +
 +
- OFF :no pull up
 +
 +
- PULLUP : input pull up
 +
 +
|}
 +
</div>
 +
&nbsp;
 +
 +
Normal AVR processors (tiny,mega) have only one option : OUTPULL.
 +
 +
The compiler will either write a 1 or 0 to the PORT register or the PUEx register.
 +
 +
&nbsp;
 +
 +
You can control a single pin using a port pin name like PORTB.0 or the whole register like PORTB.
 +
 +
<span style="font-family: Arial;">Normal AVR code that use : PORTX.Y=1 &nbsp;to activate the pull up, should be written as : CONFIG XPIN=PORTX.Y,OUTPULL=PULLUP</span>
 +
 +
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
&nbsp;
 +
 +
= <span class="f_Header">XMEGA</span> =
 +
 +
You still need to use&nbsp;<span style="font-size: 12pt; font-family: 'Times New Roman';">PORTx = state or PINx.y = state to configure the data direction of that port or pin in addition to CONFIG XPIN.</span>
 +
 +
<span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;</span>
  
 
The xmega has many more options. The Xmega manual explains all the options.
 
The xmega has many more options. The Xmega manual explains all the options.
Line 37: Line 102:
 
The pin to be configured. For example PORTC.0
 
The pin to be configured. For example PORTC.0
  
When configuring the whole port (all the pins must have the same functionality), use PORT. For example&nbsp;: PORTD
+
When configuring the whole port (all the pins must have the same functionality), use PORT. For example : PORTD
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 46: Line 111:
 
This option will invert the data for both input and output modes.
 
This option will invert the data for both input and output modes.
  
Possible values&nbsp;: ENABLED (will invert data), DISABLED(normal mode)
+
Possible values : ENABLED (will invert data), DISABLED(normal mode)
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 53: Line 118:
  
 
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |  
Will enable or disable the slewrate. Enabling the slew rate will increase the rise/fall time by 50%-150%. Possible values&nbsp;: ENABLED, DISABLED
+
Will enable or disable the slewrate. Enabling the slew rate will increase the rise/fall time by 50%-150%. Possible values : ENABLED, DISABLED
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 62: Line 127:
 
Sets the output or pull mode. The following options are available:
 
Sets the output or pull mode. The following options are available:
  
- TOTEM&nbsp;: output totem pole
+
- TOTEM : output totem pole
  
- BUSKEEPER&nbsp;: output totem pole, input bus keeper
+
- BUSKEEPER : output totem pole, input bus keeper
  
- PULLDOWN&nbsp;: output totem pole, input pull down
+
- PULLDOWN : output totem pole, input pull down
  
- PULLUP&nbsp;: output totem pole, input pull up
+
- PULLUP : output totem pole, input pull up
  
- WIREDOR&nbsp;: output wired OR
+
- WIREDOR : output wired OR
  
 
- WIREDAND: output wired AND
 
- WIREDAND: output wired AND
  
-WIREDORPULL&nbsp;: output wired OR, input pull down
+
-WIREDORPULL : output wired OR, input pull down
  
-WIREDANDPULL&nbsp;: output wired AND, input pull up
+
-WIREDANDPULL : output wired AND, input pull up
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 83: Line 148:
  
 
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 512px; border: 1px solid rgb(0, 0, 0);" |  
In input mode, the trigger sense can be configured. Possible values&nbsp;:
+
In input mode, the trigger sense can be configured. Possible values :
  
- BOTH&nbsp;: sense both edges
+
- BOTH : sense both edges
  
- RISING&nbsp;: sense rising edge
+
- RISING : sense rising edge
  
-FALLING&nbsp;: sense falling edge
+
-FALLING : sense falling edge
  
 
-LOW_LEVEL &nbsp;:sense low level
 
-LOW_LEVEL &nbsp;:sense low level
  
- INP_DISABLED&nbsp;: digital input buffer disabled (only PORTA-PORTF)
+
- INP_DISABLED : digital input buffer disabled (only PORTA-PORTF)
  
 
|}
 
|}
 
</div>
 
</div>
<span style="font-family: Arial;">&nbsp;</span>
 
 
<span style="font-family: Arial;">Normal AVR code that use&nbsp;: PORTX.Y=1 &nbsp;to activate the pul up, should be written as&nbsp;: CONFIG XPIN=PORTX.Y,OUTPULL=PULLUP</span>
 
 
<span style="font-family: Arial;">&nbsp;</span>
 
 
<span style="font-family: Arial;">&nbsp;</span>
 
 
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  

Latest revision as of 12:40, 24 August 2013

Contents

Action

Configures additional features of a processor port or pin.

 

 

 

Syntax

CONFIG XPIN=PORT|PIN, OUTPULL=pull

 

 

Syntax Xmega

CONFIG XPIN=PORT|PIN, INVERTIO=invio, SLEWRATE=slew, OUTPULL=pull, SENSE=sense

 

 

Remarks

Normal AVR port pins can be configured as an input or output. When configured as an input (CONFIG PIN=INPUT) they can also be set to tri-state (write a 0 to the PORT register) or to activate the pull up resistor(write a 1 to the PORT register).

Some new AVR processors use a special PUD register to control the pull up. The CONFIG XPIN automatically uses the proper registers to control the pull up state.

 

 

Normal AVR

PORT

PIN

The pin to be configured. For example PORTC.0

When configuring the whole port (all the pins must have the same functionality), use PORT. For example : PORTD

OUTPULL

Sets the output or pull mode. The following options are available:

- OFF :no pull up

- PULLUP : input pull up

 

Normal AVR processors (tiny,mega) have only one option : OUTPULL.

The compiler will either write a 1 or 0 to the PORT register or the PUEx register.

 

You can control a single pin using a port pin name like PORTB.0 or the whole register like PORTB.

Normal AVR code that use : PORTX.Y=1  to activate the pull up, should be written as : CONFIG XPIN=PORTX.Y,OUTPULL=PULLUP

 

 

 

XMEGA

You still need to use PORTx = state or PINx.y = state to configure the data direction of that port or pin in addition to CONFIG XPIN.

 

The xmega has many more options. The Xmega manual explains all the options.

The CONFIG XPIN statement will set the proper registers.

 

PORT

PIN

The pin to be configured. For example PORTC.0

When configuring the whole port (all the pins must have the same functionality), use PORT. For example : PORTD

INVERTIO

This option will invert the data for both input and output modes.

Possible values : ENABLED (will invert data), DISABLED(normal mode)

SLEWRATE

Will enable or disable the slewrate. Enabling the slew rate will increase the rise/fall time by 50%-150%. Possible values : ENABLED, DISABLED

OUTPULL

Sets the output or pull mode. The following options are available:

- TOTEM : output totem pole

- BUSKEEPER : output totem pole, input bus keeper

- PULLDOWN : output totem pole, input pull down

- PULLUP : output totem pole, input pull up

- WIREDOR : output wired OR

- WIREDAND: output wired AND

-WIREDORPULL : output wired OR, input pull down

-WIREDANDPULL : output wired AND, input pull up

SENSE

In input mode, the trigger sense can be configured. Possible values :

- BOTH : sense both edges

- RISING : sense rising edge

-FALLING : sense falling edge

-LOW_LEVEL  :sense low level

- INP_DISABLED : digital input buffer disabled (only PORTA-PORTF)

 

See also

CONFIG PINCONFIG INT

 

Example


Config Porte.5 = Input
Config Xpin = Porte.5 , Outpull = Pullup , Sense = Falling 'enable Pull up and reaction on falling edge

$regfile = "xm256a3budef.dat"
$Crystal = 32000000 '32MHz
 
Config Xpin = Portc.0 , Slewrate = Enabled , Outpull = Buskeeper , Sense = Low_level
Config Xpin = Portc.1 , Slewrate = Enabled , Outpull = Buskeeper , Sense = Low_level
 
'setup the whole port at once
Config Xpin = Portd , Slewrate = Enabled , Outpull = Buskeeper , Sense = Low_level

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language