Avr Studio Simulator / gcc

Gast #426086
Lesenswert?

Hallo,
habe folgenden Code mit dem avr-gcc übersetzt
#include<avr\io.h>
#include<avr\interrupt.h>

void init_Ex4(void)
{
  TCCR2 = (1<<WGM20)+(1<<COM21)+(1<<CS20); // Timer2 sysf/1
  DDRB = 0xFF;  // Portb ausgang
  PORTB = 0x08; // test
  OCR2 = 0xE0;  // Compare Value
}

int main()
{
  init_Ex4();
  while(1);
  //OCR2++;
  return(0);
}


aus;

OCR2 = 0xE0;

macht der gcc
LDI     R24,0xE0         Load immediate
STS     0x0043,R24       store direkt to sram

(ausschnitt aus dem disassambly)

und dementsprechend funktioniert auch nix. Der Simulator zeigt die 
änderung von ocr2 etliche takte später an. Kann mir da jemand helfen?

Florian
Persönliche Seite #426108
Lesenswert?

Das hat einen ganz einfachen Grund

>>The OCR2 Register is double buffered when using any of the Pulse Width 
Modulation
>>(PWM) modes. For the normal and Clear Timer on Compare (CTC) modes of operation,
>>the double buffering is disabled. The double buffering synchronizes the update 
of the
>>OCR2 Compare Register to either top or bottom of the counting sequence. The 
synchro-
>>nization prevents the occurrence of odd-length, non-symmetrical PWM pulses, 
thereby
>>making the output glitch-free.
>>The OCR2 Register access may seem complex, but this is not case. When the double
>>buffering is enabled, the CPU has access to the OCR2 Buffer Register, and if 
double
>>buffering is disabled the CPU will access the OCR2 directly.


Sprich: Im PWM Mode wird dein OCR2 erst beim TOP(oder BOTTOM) Value 
geupdated. Solange verharrt der Wert in einem Buffer..
Persönliche Seite #426134
Lesenswert?

jay wrote:
> @simon
>
> Wie hastn das rauskopieren können....sind die Datenblätter nicht
> verschlüsselt?

*g Könnte ich es dann lesen? In meinem Foxit PDF Reader klicke ich das 
Textauswahlsymbol an, und ziehe einen Rahmen um den Text. Dann kann ich 
ihn irgndwo anders auch schon einfügen.


Man kann in der Project Configuration auch noch einstellen, dass ein 
"Listing" erstellt wird. Sprich: Es wird im Debug Ordner eine .lss mit 
Assemblerbefehlen + C-Code und Kommentare gebaut.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren