--- In "ejeffredo" <> wrote:
>
> Hi all,
>
> I need some explanation for dio register. For example :
>
> PBDDR = 0xf0 means dio 0 to 3 : input and dio 4 to 7 : output
> PBDR = 0x01 : all dio =0 except dio 0 = 1
>
> Thanks,
>
> Manu
>
Hi Manu,
You need to be a bit more specific about your question. Looking at what you
wrote (and not referencing anything else).
The digital I/O port (PB) above consists of two registers, the data direction
register (PBDDR) which tells the port which of the eight bits are inputs (0) or
outputs (1). The data is then read/written to the data register (PBDR), where
reads from the register will read the inputs, and writes to the register set
the state of the outputs.
In your above example:
Bit 0: = 0x01 HEX
Bit 1: = 0x02 HEX
Bit 2: = 0x04 HEX
Bit 3: = 0x08 HEX
Bit 4: = 0x10 HEX
Bit 5: = 0x20 HEX
Bit 6: = 0x30 HEX
Bit 7: = 0x40 HEX
Thus to set the data direction register for bits 4 to 7 to be outputs you add
them up 0x10 + 0x20 + 0x40 + 0x80 = 0xF0.
The PBDR=0x01 does not match with the PBDDR setting above as the PBDR
instruction is trying to write an output to a pin set as an input. More likely
would be PBDR=0x10 which would set output 4 on.
Hope this makes things clearer.
PJE
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|