Rainbow-electronics ATtiny10 Manual do Utilizador Página 45

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 166
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 44
45
8127B–AVR–08/09
ATtiny4/5/9/10
10.2.7 Program Example
The following code example shows how to set port B pin 0 high, pin 1 low, and define the port
pins from 2 to 3 as input with a pull-up assigned to port pin 2. The resulting pin values are read
back again, but as previously discussed, a nop instruction is included to be able to read back the
value recently assigned to some of the pins.
Note: See “Code Examples” on page 5.
10.3 Alternate Port Functions
Most port pins have alternate functions in addition to being general digital I/Os. In Figure 10-6
below is shown how the port pin control signals from the simplified Figure 10-2 on page 41 can
be overridden by alternate functions.
Assembly Code Example
...
; Define pull-ups and set outputs high
; Define directions for port pins
ldi r16,(1<<PUEB2)
ldi r17,(1<<PB0)
ldi r18,(1<<DDB1)|(1<<DDB0)
out PUEB,r16
out PORTB,r17
out DDRB,r18
; Insert nop for synchronization
nop
; Read port pins
in r16,PINB
...
Vista de página 44
1 2 ... 40 41 42 43 44 45 46 47 48 49 50 ... 165 166

Comentários a estes Manuais

Sem comentários