Forum: Mikrocontroller und Digitale Elektronik C Code für ARM erklären


von Andreas R. (blackpuma)


Lesenswert?

Hallo Board!

Ich habe hier ein Stück C Code für einen ATmega8. Kann allerdings kein C 
für das Teil bzw. nur recht wenig. Vielleicht kann mir das jemand 
erklären. Im speziellen:

1. Was ist das SPDR?

2. Was macht das Wait()?

Sollte der Code jemandem bekannt vorkommen: Er ist von der Seite 
http://garydion.com/projects/videoverlay/


####################################################
if ((line > 40) && (line < 48))
  {
    SPSR = 0;
    ltemp = (line - 41) * 27 - 64;
    ntemp = (line - 41) * 14 - 45;
  DDRD  = 0x80;              /* Data direction register for port D    */
    SPDR = ltrs[head[0] + ltemp];  Wait();
    SPDR = nums[head[1] + ntemp];  Wait();
    SPDR = ltrs[head[2] + ltemp];  Wait();
    SPDR = ltrs[head[3] + ltemp];  Wait();
    SPDR = ltrs[head[4] + ltemp];  Wait();
    SPDR = ltrs[head[5] + ltemp];  Wait();
    SPDR = ltrs[head[6] + ltemp];  Wait();
    SPDR = ltrs[head[7] + ltemp];  Wait();
    SPDR = ltrs[head[8] + ltemp];  Wait();
    SPDR = ltrs[head[9] + ltemp];  Wait();
    SPDR = ltrs[head[10] + ltemp];  Wait();
    SPDR = ltrs[head[11] + ltemp];  Wait();
    SPDR = ltrs[head[12] + ltemp];  Wait();
  DDRD  = 0x00;              /* Data direction register for port D    */
  }
####################################################

von Gast (Gast)


Lesenswert?

SPDR: SPI-Datenregister, siehe Datenblatt zu ATmega8
Wait(): "wait" = "warten", vermutlich soll die CPU ein wenig warten

von Johannes M. (johnny-m)


Lesenswert?

Der ATMega8 ist ein AVR und kein ARM!

SPDR ist das SPI-Datenregister (siehe Datenblatt und 
AVR-GCC-Tutorial).

Was wait() macht, kann man ohne Kenntnis des kompletten Codes nicht 
sagen, da es keine Standard-Funktion ist. Vermutlich wartet es...

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.