AVR-0 Core independent LED fading?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmega 3209 (AVR 0 series).  I understand an led fading effect can be accomplished with pulses but I might not want to have my AVR distracted as it's got some pretty time intensive things to handle and interrupts to look out for.  Maybe it's got the time to spare, I don't know, I'll explore that later but I was wondering if there are any tricks to handle such things in a way that doesn't tax the CPU?  The datasheet says it's got an "Event System for core independent and predictable inter-peripheral signaling."  Before I start barking up the wrong tree I was wondering if that could be used for to accomplish something like simulating an LED fade?  Of course I don't need to fade an LED but word on the street is that it's what all the cool kids are doing.

 

Thank you.

 

BTW, I have already started looking at 'Getting Started with Core Independent Peripherals on AVR' (http://ww1.microchip.com/downloa...) but haven't gotten too deep yet.  I'm mostly looking to find out if it's a possible solution or not so I can save myself the effort if not.

Last Edited: Thu. Sep 5, 2019 - 04:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A timer with a PWM output can do the fading all in hardware, and the cpu only needs to supply the fade value to one register (Output Compare Reg), so pretty low CPU intensity, an usually not time critical.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First question: how many LEDs?  Followup question: how many independent LED intensity channels?  The latter refers to how many different intensities you want active at the same time.  Driving 20 LEDs all with the same intensity value only implies 1 channel.  Driving 20 LEDs each with different intensity implies 20 channels.

Last Edited: Thu. Sep 5, 2019 - 10:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think there is a way to do it fully auto without a DMA controller. Since the mega3209 doesn't have one, you can use the method i #2.

 

That is, one timer generates a PWM waveform, and at the same time it calls an interrupt, or maybe a different timer calls an interrupt. Anyway, the interrupt routine will change the PWM duty cycle to cause the fade effect.

Unfortunately, the Event System can't write registers automatically, as I said, only a (non-existant) DMA peripheral could do that. You need to endure the ISR overhead.