3
I also doubt parasitic capacitance is the issue here. I simulated a circuit with 100pF to ground (a huge amount) and a faux mosfet gate termination. and only saw ~5mA though it with rise/fall times of 100ns. If your rise times are much faster you will see more current, but according to this post:
How solder inductance affects RF circuits?
you'd be lucky ...
2
You are not using an external "Crystal Oscillator", you have an external crystal.
An external oscillator is an active device that produces a signal by itself, a crystal (or a resonator) is a passive component that is a resonant element to control the frequency of the oscillator internal to the AVR.
This is a fairly common error that people make that is not ...
2
Is there a good way to solve this with virtually no overhead?
There is no practical way to get 'virtually no overhead' in C on AVR. Code that looks like it should have low overhead often doesn't, and you have to look at the disassembly to see the real code.
AVR has a RISC architecture that needs many instructions to do 'simple' operations. IN, OUT, and SBI/...
1
Unfortunately you can't have a pointer to certain bit of port directly.
If a struct that for each led contains both the port address and bit index is too wasteful, use one more level of indirection.
I introduce a concept of LED Handle which is simply a byte to conveniently point indirectly to an IO port and bit in it.
First, generate a table that contains ...
1
How about a structure of the addresses?
//PORTD = 0x10000
struct {
void * 0x10000;
void * 0x10001;
void * 0x10002;
...
// PORTB = 0x20000
void * 0x20000;
void * 0x20001;
etc.
}
Then you can iterate over the structure.
1
I think since you have absolutely NO experience, you should learn with an arduino uno board. These boards are ready-to use for beginners and include an ATmega328p AVR microcontroller. You can find tons of tutorials on the internet for the Arduino device family and there's a lot to learn. Have fun!
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
avr × 1646atmega × 383
microcontroller × 350
arduino × 202
c × 179
attiny × 118
atmel × 111
interrupts × 109
uart × 85
avrdude × 82
avr-gcc × 81
spi × 79
pwm × 65
adc × 63
timer × 62
isp × 60
assembly × 55
usb × 53
i2c × 53
serial × 48
programming × 46
programmer × 43
embedded × 37
bootloader × 36
atmega328p × 36