Forum: Mikrocontroller und Digitale Elektronik Frage zum SAM3S4B


von Marco B. (x8x8x)


Lesenswert?

Hallo,
ich bin blutiger Anfänger was Mikrocontroller anbelangt, daher meine 
Frage zur "Output Control". Ich verstehe nicht ganz, wofür ich PIO_SODR 
bzw. PIO_CODR brauche. Im Datenblatt ist es erklärt, verstehe es aber 
nicht, da ich keinen Bezug dazu habe:

-----------------------------------------------------------------------
When the I/0 line is assigned to a peripheral function, i.e. the 
corresponding bit in PIO_PSR is at 0, the drive of the I/O line is 
controlled by the peripheral. Peripheral A or B or C or D depending
on the value in PIO_ABCDSR1 and PIO_ABCDSR2 (ABCD Select Registers 
determineswhether the pin is driven or not.

When the I/O line is controlled by the PIO controller, the pin can be 
configured to be driven. This is done by writing PIO_OER (Output Enable 
Register) and PIO_ODR (Output Disable Register).
The results of these write operations are detected in PIO_OSR (Output 
Status Register). When a bit in this register is at 0, the corresponding 
I/O line is used as an input only. When the bit is at 1, the 
corresponding I/O line is driven by the PIO controller.

The level driven on an I/O line can be determined by writing in PIO_SODR 
(Set Output Data Register) and PIO_CODR (Clear Output Data Register). 
These write operations respectively set and clear PIO_ODSR (Output Data 
Status Register), which represents the data driven on the I/O lines. 
Writing in PIO_OER and PIO_ODR manages PIO_OSR whether the pin is 
configured to be controlled by the PIO controller or assigned to a 
peripheral function. This enables configuration of the I/O line prior to 
setting it to be managed by the PIO Controller.

Similarly, writing in PIO_SODR and PIO_CODR effects PIO_ODSR. This is 
important as it
defines the first level driven on the I/O line.
--------------------------------------------------------------------


Danke

x8x8x

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Marco B. schrieb:
> Ich verstehe nicht ganz, wofür ich PIO_SODR bzw. PIO_CODR brauche.

Um einzelne Portpins (effektiv) setzen oder löschen zu können, ohne
dass man zuvor das ganze Register manuell zurücklesen müsste.

Ist also in etwa das, was beim AVR die Befehle SBI und CBI machen.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.