View previous topic :: View next topic |
Author |
Message |
W4GNS
Joined: 03 Dec 2009 Posts: 11 Location: (Virginia)
|
Posted: Sun Aug 07, 2011 11:25 pm Post subject: Scrolling LEDs with Sure Electronics ATmega 16 Demo Board |
|
|
Howdy Folks
I just loaded the following code into a Sure Elect Demo Board and they are not behaving as expected. PortA.1 and PortA.2 light at the same time and start dim, then brighten up. I'm certain that I forgetting to set something but not sure what, any comments/suggestions ?
Thanks Gary - W4GNS
Code: |
'******************************************************
'* Blink LED's using Sure Electronics AVR Dem2
'* ATmega16
'*
'******************************************************
$regfile = "m16def.dat"
$crystal = 12000000
$hwstack = 80
$swstack = 40
$framesize = 60
'$sim
Config Porta = Output
Led Alias Porta.0
Led1 Alias Porta.1 'leds pa0,pa1,pa2,pa3
Led2 Alias Porta.2
Led3 Alias Porta.3
Do
Toggle Led
Waitms 500
Toggle Led1
Waitms 500
Toggle Led2
Waitms 500
Toggle Led3
Waitms 500
Loop
|
_________________ Bascom-AVR 2.0.7.6
Programmer USBASP (China Version) |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sun Aug 07, 2011 11:54 pm Post subject: |
|
|
If the brightness changes as you turn on more LEDs, it sounds like you draw far too much current from the port pins. Max current from a port pin is 20mA. You do have resistors ( typically about 1K ) in series with the LEDs ? _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
W4GNS
Joined: 03 Dec 2009 Posts: 11 Location: (Virginia)
|
Posted: Sun Aug 07, 2011 11:59 pm Post subject: |
|
|
Yup, all is as should be as far as resistors go, this is a pre fab demo board that can be seen here http://www.sure-electronics.com/gallery.php?id=244
Actually I think 1 LED should be lit at a time,but it's not working out like that, thus the issue
AdrianJ wrote: | If the brightness changes as you turn on more LEDs, it sounds like you draw far too much current from the port pins. Max current from a port pin is 20mA. You do have resistors ( typically about 1K ) in series with the LEDs ? |
_________________ Bascom-AVR 2.0.7.6
Programmer USBASP (China Version) |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Mon Aug 08, 2011 3:22 am Post subject: |
|
|
Program looks right to me.
The LEDs are active when the port pins are low, according to the schematic. So they should be on when you first turn on the power ( a Reset sets all ports to 0, then the config porta = output would set the lines to output, so all the lines should drive low. )
If this is not what happens, maybe the program is not loaded correctly, or the fuses are not set.
Even without the fuses set, it should do something, maybe at the wrong speed, since by default the internal oscillator will be running, at 1 MHz, so the speed will be about 12x lower than you think, since you specify a 12 mHz clock in Bascom. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|