User Tools

Site Tools


info:avr32_gpio_writing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
info:avr32_gpio_writing [2009/04/28 08:47] tomgeeinfo:avr32_gpio_writing [2009/04/29 09:59] (current) tomgee
Line 41: Line 41:
 If you just want to toggle one or more bits use If you just want to toggle one or more bits use
 OVRT = Bit(x); and this bit has the inverted level without influencing the others during that operation. OVRT = Bit(x); and this bit has the inverted level without influencing the others during that operation.
-If you want to set some bits to a specific value like for your display port you can also use toggle instead of clearing all and setting the used once like+If you want to set some bits to a specific value like for your display port you can also use toggle instead of clearing all and setting the used ones like
      OVRT = (OVR & AllBitMask) ^ (NewValue << Offset);      OVRT = (OVR & AllBitMask) ^ (NewValue << Offset);
-Here you used the read function as well as the toggle function and set all bits simultaneously. Independent of there level.+Here you used the read function as well as the toggle function and set all bits simultaneously, independent of their level.
  
 The GPER(S/C/T) is used logically the some way to use a port pin as a port pin or not. If you clear it the port pin is connected to one of the internal modules like USART, TWI, SPI or Timer. You have to set GPER to use a port pin as a port pin. But don't forget to set the output driver too. Otherwise you have a port pin but you output value is not driven. The GPER(S/C/T) is used logically the some way to use a port pin as a port pin or not. If you clear it the port pin is connected to one of the internal modules like USART, TWI, SPI or Timer. You have to set GPER to use a port pin as a port pin. But don't forget to set the output driver too. Otherwise you have a port pin but you output value is not driven.
 If you want a pure output you should also clear the ODMER otherwise you have an open drain driver if the device is populated with it.\\ If you want a pure output you should also clear the ODMER otherwise you have an open drain driver if the device is populated with it.\\
 And last but not least you should also clear the PUER to keep your power consumption low.  And last but not least you should also clear the PUER to keep your power consumption low. 
 +
 +===== Setting Clock =====
 +
 +    pm_freq_param_t osc;
 +    osc.cpu_f = 66000000;
 +    osc.osc0_f = FOSC0;
 +    osc.osc0_startup = FOSC0_STARTUP;
 +    osc.pba_f = 33000000;
 +    pm_configure_clocks(&osc); 
 + 
 +
 +You can set and reset the port pins directly. Here is an example for PORTB:
 +Code:
 +volatile avr32_gpio_port_t *gpio_port_b = ( volatile avr32_gpio_port_t * ) &gpio_base->port[1];
 +   
 +gpio_port_b->ovrc = 0x00000001; // Clear PORTB0
 +gpio_port_b->ovrs = 0x00000001; // Set PORTB0
 +
 +
 +===== Setting PIO Faster =====
 +
 +This is faster, because you don't have to call a function (saving and restoring of all registers => stack).
 +
 +If you want to set or reset a pin of PORTA:
 +
 +    volatile avr32_gpio_port_t *gpio_port_a = ( volatile avr32_gpio_port_t * ) &gpio_base->port[0];
 +   
 +    gpio_port_a->ovrc = 0x00000001; // Clear PORTA0
 +    gpio_port_a->ovrs = 0x00000001; // Set PORTA0
 +
 +
 +You can also set or reset more than one pin at the same time. 
info/avr32_gpio_writing.1240922875.txt.gz · Last modified: 2009/04/28 08:47 by tomgee