Software Time Delays

Software Time Delays - o o o mov cx, timeval2 mov dx,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Software Time Delays 1. Short Time Delays o o o mov cx, timeval1 call delay1 o o o Clks delay1: dec cx 3 nop 3 jnz delay1 16/4 ret 16 a. Time of execution equation: Te| delay1 = 1/fCLK [22(CX – 1) + 10 + 16] = tCLK [22(CX – 1) +26] = tCLK [22CX – 22 + 26] = tCLK [22CX + 4] Example: Assume fCLK = 5 MHz and the desired delay = 10 milliseconds. Te = 200ns [22CX + 4] = 10ms
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CX = [(10 * 10 -3 /0.2 * 10 -6 ) – 4] / 22 = 49,996 / 22 = 2272 10 (= 8E0h) Therefore, timeval1 = 08E0h. b. What value of timeval1 would generate the shortest time delay in the delay1 routine? Longest time delay? Some thoughts: 1) The shortest time would be to pass through the delay 1 routine once without making any loops. 2) The longest time would occur when the value chosen for timeval1 would loop as many times as possible for a 16-bit number. 3) The value 0000h decremented back to 0000h is equivalent to 65,536 iterations. 2. Long Time Delays
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: o o o mov cx, timeval2 mov dx, timeval3 call delay2 o o o Clks delay2: dec cx 3 nop 3 jnz delay2 16/4 dec dx 3 nop 3 jnz delay2 16/4 ret 16 a) Time of execution equation: Te| delay2 = 1/fCLK {22(CX 1) + 10 + [22(65535) + 10 + 22](DX 1) + 10 + 16} = tCLK {22(CX 1) + [1441802](DX 1) + 36} Example: Assume fCLK = 10MHz and desired delay = 500 milliseconds. The longest count is from the (DX 1) term. So lets choose a value for DX to get close to the 500 ms value, then we will solve the Te equation for CX to trim into the 500 ms value. Choose DX = 4, then 100ns [1441802](4 1) = 0.432 sec. 100ns {22(CX 1) + [1441802](3) + 36} = 500ms 100ns {22CX + 4325420} = 500ms CX = (5000000 4325420) / 22 = 30,663d (= 77C7h) Therefore, o timeval2 = 77C7h o timeval3 = 0004h...
View Full Document

Page1 / 3

Software Time Delays - o o o mov cx, timeval2 mov dx,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online