Docsity

Slide Notes for Embedded Systems Programming - Assembly Language Programming | ETEE 3285, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Slide Notes for Embedded Systems Programming - Assembly Language Programming | ETEE 3285 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Embedded Systems Programming

ETEE 3285

Topic 17: Square waves

Objectives

 Gain a better understanding of the

ATmega128 and assembly language

programming

 Developing output waveforms (square

waves)

 Specific frequency

 Specific duty cycle

 Multiple square waves

Task

 Suppose:

 We want to output a square wave

 With a specific frequency 10 kHz  With a specific duty cycle 50% duty cycle

 What would we have to do?

 How would you write the program?

We’ll consider applications soon

Square Wave

f T

T

tH tL

DutyCycle t t t

t T

H H L

* 100% H *100%

The Plan

1. Initialize ports

2. Set the output bit

1. Delay for 50 s

3. Clear the output bit

1. Delay for 50 s

4. Go back to step 2

Square Wave

T

f k

(^1 1) s 10

T

tH tL

t (^) H DutyCycle^^ *^ T^ * s^ s 100%

Exercise: What would be the time high and time low if you needed a 5kHz, 25% duty cycle square wave?

Task

 Suppose:

 We want to output 2 square waves

simultaneously

 Each with a specific frequency  Each with a specific duty cycle

 What would we have to do?

 How would you write the program?

Square Wave

This is what we need. How would you approach it?

f = 2kHz

f = 1kHz

Square Wave

f = 2kHz

f = 1kHz

  1. Output 1 on b0 and 1 on b1 for 250 s
  2. Output 1 on b0 and 0 on b1 for 250 s
  3. Output 0 on b0 and 0 on b1 for 250 s
  4. Output 0 on b0 and 0 on b1 for 250 s
  5. Go back to step 1

250 s 250 s 250 s 250 s

Waveform 1 on bit0 Waveform 2 on bit

Task

 Suppose:

 We want to output 2 square waves

simultaneously

 Each with the same frequency  Each with the same duty cycle  90° out of phase

 What would we have to do?

 How would you write the program?

Square Wave

I would take the same approach as before and divide the waveforms into segments at the transitions. If both waveforms were 5kHz then we would need 50μs

50 s 50 s 50 s 50 s

W 1

W 2

Task

 Suppose:

 We want to output 3 square waves

simultaneously

 Each with different frequencies  Each with different duty cycles  All out of phase with the others

 What would we have to do?

 How would you write the program?

Summary

 In this topic we:

 Gained a better understanding of the

ATmega128 and assembly language

programming

 Developed output waveforms (square waves)

 Specific frequency  Specific duty cycle  Multiple square waves