Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AVR Best time possible Pulse width change Ph. correct top = ICR1

Status
Not open for further replies.

azadfalah

Full Member level 2
Full Member level 2
Joined
Aug 13, 2016
Messages
145
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,423
Hello friends


what is Best time possible Pulse width change Ph. correct top = ICR1

I act as follows, is it correct?


Code C - [expand]
1
2
3
4
5
if(SetNewvalue) {
     while(TCNT1H != OCR1AH && TCNT1L != OCR1AL);    
     OCR1AH=0x0C; // set New Value
     OCR1AL=0x80;  // set New Value
}

 

Hi,

Read the datasheet.

It tells that OCRxx registers are double bufferd and are automatically (by hardware) updated at TOP or BOTTOM or immediately depending on seleted WGM

Klaus
 
I was not able to understand anything at all from your question as you did not spent much effort to elaborate, but by looking at it, the evaluation of the 16-bit timer at 2 different moments sounds like weird, since depending on whether the values are close to the overflow of the lowest register, after updating the higher register can give a false result.

I would do something like this:

Code:
     while(TCNT1 != OCR1A);

Instead of this:

Code:
     while(TCNT1H != OCR1AH && TCNT1L != OCR1AL);

Regardless of whether your updating logic is correct or not.
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top