So, I’ve never dabbled in C until now while using it with AVR microcontrollers – and while trying to complie a simple for loop:
for (uint8_t bit = 0x80; bit; bit >>= 1) {
...
}
I got this error:
error: 'for' loop initial declaration used outside C99 mode
and to fix it I would move my decloration of the varabile outside of the loop. This seemed stupid to me so a quick Google search turned up this
Back in the old days, when dinosaurs roamed the earth and programmers used punch cards, you were not allowed to declare variables anywhere except at the very beginning of a block.
Solution was to add -std=c99 to the Makefile. My new AVR Makefile now looks like this..
Posted: June 15th, 2011 | Author: jay | Filed under: Code, Electronics | Tags: attiny, avr, avr-gcc, c, c99, gcc, makefile | No Comments »
Based on Atmel’s AVR136: Low-Jitter Multi-Channel Software PWM Application note, here’s a 3 channel software-based pulse width modulator to drive a RGB LED. This is a proof of concept and currently there is some in-efficient color cycling code in there, but the goal is to drive these cheap chips using an I2C (two wire serial) bus. Disco dance floor anyone?…
Posted: May 4th, 2011 | Author: jay | Filed under: Code, Electronics | Tags: atmel, attiny, attiny85, c, i2c, led, pulse width, pwm, rgb | No Comments »
avrdude -c dragon_hvsp -p attiny85 -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -P usb
Posted: May 3rd, 2011 | Author: jay | Filed under: Electronics | Tags: atmel, attiny, avr dragon, avrdude, dragon_hvsp, fuse, high voltage, reset | No Comments »
This is what I’m using as a Makefile – based on what was included in a downloaded XCode template project – Can’t remember where I downloaded the starting point, but thanks…
Posted: April 26th, 2011 | Author: jay | Filed under: Code, Electronics | Tags: attiny, avr, make, makefile, usbtiny | No Comments »