18/08/2013
Embedded Systems Design ELEN90066
Lecture 7 LEDs, SPI, LCD,RAM & ADC David Jahshan
Notes from last lecture
• Don’t leave inputs floating • D Flip Flop toggling
• Debouncing push buttons • Interrupts vs polling
Example exam question
• Why would you not have an external pull-up resistor on an input to the ATMEGA 16?
• If you had a 1mAh battery and a device uses 1uA in standby how many days will it take before the battery is depleted
• This question would probably be asked with a graph
• Always answer the question asked.
LEDs Specs
• 1.6 A green LED will illuminate if the power is on.
• 4.2 A red LED will illuminate if the power level is lower than 1.1 volts.
• 6.4 The device will have a green LED to indicate power output from the regulator. (repeat of 1.6)
• 6.5 The device will have a red LED controlled by the microcontroller. (repeat of 4.2)
Sourcing or syncing current
• You can tie the LED to VCC and the other side to the microcontroller via a resistor.
– The microcontroller will be syncing current • Active low but more current.
• You can tie the LED to GND and the other side to the microcontroller via a resistor.
– The microcontroller will be sourcing current
Driving the backlight • Just another LED
– Has two LEDs (more internally), do you run them in series or parallel?
• You can control the brightness using PWM
• Make sure you pick a pin that has a PWM output
1
18/08/2013
Light Emitting Diodes
• Light Emitting Diodes are diodes that emit light when forward biased.
• Voltage drop across a diode depends on the colour of the diode.
• Current across an ideal diode is infinite, must always have a
resistor in series or
magic smoke escapes.
MOSFET
• Too much current required to switch directly • 80mA each
SPI
• Serial Peripheral Interface
• Synchronous communication protocol
– Master supplies a clock
– Data is sampled on clock edge – MOSI Master Out Slave In
– MISO Master In Slave Out
• Synchronsiation is not required
• Multiple items can have a Chip Select Pin
Interfacing to LCD
• Input only, can not read back from the LCD.
• SCK to SCK/SCL (different manufacturers use different names)
• SDA to MOSI (The ATMEGA is the master)
• CS, CD and RESET to an IO pin to select the chip
– SS pin for CS is only used in input mode you can pick any pin for SS.
Power to the LCD • Wire up your LCD this way
Interfacing to FRAM
• What is FRAM
– Ferrous Random Access Memory stores data bits in the spin of electrons (magnetic fields) and is non volatile (you can power cycle and keep info)
– Also SPI based but is bidirectional
• FRAM can be used to store frame buffers and
states of your software between power cycles.
• Unlike flash it is fast to write and does not degrade with number of writes.
2
18/08/2013
Interfacing to FRAM
• Bidirectional
– ATMEGA is master
• SCK to SCK
• MOSI to SI
• MISO to SO
• Wire up CS, WP, and HOLD to general IO
– Discuss the actual protocol at a later date
ADC
• Analogue Digital Converters take an analogue input and outputs a digital representation of the voltage.
• There are a number of ADC pins on the chip.
• Battery voltage is 0 to 1.5v
• Internal reference of 2.56v
• AREF and AVCC do not require inductor
• Crystals
• PCB layout
Next Lecture
3