AN2387
Core Independent Nightlight Using Configurable Custom
Logic on ATtiny1617
Features
Low CPU Usage
Core Independent Operation using a Configurable Custom Logic (CCL) Module
Event System
TCA0 – 16-Bit Timer/Counter Type A
SPI0 – Serial Peripheral Interface
AC0 – Analog Comparator
DAC – Digital-to-Analog Converter
EEPROM Data Memory
Passive Infrared Detector
Ambient Light Sensor
16 Intelligent Addressable RGB LEDs
Introduction
This application note describes the use of Core Independent Peripherals (CIP), how to use the
Configurable Custom Logic (CCL) to filter inputs from different sensors, and how to create specific
communication protocols using a Microchip AVR
®
device, a Passive InfraRed sensor (PIR), Ambient Light
Sensor, and 16 addressable RGB LEDs. Many peripherals are configured to work together, independent
of the CPU.
The light should turn ON only when it is sufficiently dark and there is movement in front of the PIR sensor.
The implementation uses the AVR Configurable Custom Logic module to determine when this occurs.
Updating the addressable RGB LEDs take advantage of timer/counter PWM generation, SPI, and CCL to
generate the specific single-line serial protocol.
© 2017 Microchip Technology Inc.
Application Note
DS00002387B-page 1
Table of Contents
Features.......................................................................................................................... 1
Introduction......................................................................................................................1
1. Relevant Devices.......................................................................................................3
1.1. tinyAVR 1-Series.......................................................................................................................... 3
2. Components.............................................................................................................. 4
2.1. STK600........................................................................................................................................ 4
2.2. Passive Infrared Detector.............................................................................................................4
2.3. Ambient Light Sensor................................................................................................................... 5
2.4. Intelligent Control LED................................................................................................................. 5
3. Implementation.......................................................................................................... 7
3.1. System Overview......................................................................................................................... 7
3.2. Connections................................................................................................................................. 7
3.3. CCL Configuration........................................................................................................................9
3.3.1. LUT0 Configuration........................................................................................................9
3.3.2. LUT1 Configuration........................................................................................................9
3.4. Program Flow............................................................................................................................. 11
4. Get Source Code from Atmel START...................................................................... 14
5. Revision History.......................................................................................................15
The Microchip Web Site................................................................................................ 16
Customer Change Notification Service..........................................................................16
Customer Support......................................................................................................... 16
Microchip Devices Code Protection Feature................................................................. 16
Legal Notice...................................................................................................................17
Trademarks................................................................................................................... 17
Quality Management System Certified by DNV.............................................................18
Worldwide Sales and Service........................................................................................19
AN2387
© 2017 Microchip Technology Inc.
Application Note
DS00002387B-page 2