NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » 9 bit fast PWM, OCR1A

June 08, 2011
by kayrock
kayrock's Avatar

I have a timer set up with fast PWM and ICR1 = 0x1FF;

Assuming that value is a uint16_t in the range 0-511 do these both do the same thing?

// Version A
OCR1A = value;

// Version B                                            
OCR1AL = value;                                                                                                    
value = value>>8;                                                                                                   
OCR1AH = value;
June 09, 2011
by kayrock
kayrock's Avatar

Ok, to answer my own question, these two bit of code create the same two assembler instructions

// Version A
OCR1A = value;

// Version B
OCR1AH = value>>8;
OCR1AL = value;

Post a Reply

Please log in to post a reply.

Did you know that you can aim and fire a servo-controlled water gun from your computer? Learn more...