Hot answers tagged

12

In terms of the core language features, there's virtually no difference. In the background, the Arduino IDE and Atmel/AVR Studio both use GCC to compile the code. GCC is an excellent toolset which supports all the core language features of C++. Admittedly, the version which currently comes with the Arduino IDE is a little old, so it doesn't support C++11 ...


10

No, the ATmega's ISP does not operate over the UART pins but only the ISP pins. To program it via a UART, you need to first load a bootloader, unless your chip was pre-programmed by the vendor, something some offer as a value-added service (or even as an essential stock item, with an Arduino type bootloader)


9

From the OSX System Report we learn that your board is based on an SiLabs CP2102 converter (or workalike), but according to your question you installed the drivers for an entirely different product from FTDI (Arduino.cc has used FTDI in the past and CDC/ACM today, I don't believe they have ever used SiLabs so their instructions probably don't cover that, ...


9

The Arduino core does things at startup. One of those things is to configure the timers ready for PWM operation. Here's the relevant bits from init() in wiring.c: // set timer 1 prescale factor to 64 sbi(TCCR1B, CS11); #if F_CPU >= 8000000L sbi(TCCR1B, CS10); #endif #if defined(TCCR1A) && defined(WGM10) sbi(TCCR1A, WGM10); #...


8

This is absolutely nothing to do with "why can't the atmel attiny family delay over a minute?". It is all to do with the way that C++ works. See my page about Integer arithmetic and overflow. To excerpt from that: On the Arduino (Uno) platform, what do you think will be printed here? void setup () { Serial.begin (115200); Serial.println (); ...


8

Burning the bootloader via the Arduino IDE also sets the fuse bits according to its configuration files.


8

The simple answer is: they are not handled at all. According to the C and C++ standards, what you are invoking is called undefined behavior, meaning anything can happen. In practical terms, it means that the compiler can do its optimizations assuming you will never invoke undefined behavior, and completely disregard what could happen if the assumption does ...


7

First, figure out which port and pin you're using. Then, manipulate them. DDRC &= ~_BV(PC5); PORTC |= _BV(PC5); ... DDRF &= ~_BV(PF5); PORTF |= _BV(PF5); ... DDRF &= ~_BV(PF0); PORTF |= _BV(PF0);


7

I am afraid there is no good solution to this problem. One option I do like is to use the __flash qualifier instead of PROGMEM: const uint8_t ram_array[] = { 1, 2, 3, 4 }; __flash const uint8_t flash_array[] = { 5, 6, 7, 8 }; void function_reading_ram(const uint8_t *array) { uint8_t secondElement = array[1]; // ... } void function_reading_flash(...


6

To join the bus as a master you cannot supply a 7-Bit slave address so your code has two slaves. Below you will find 2 sketches that successfully sends data to a slave. I would suggest you start looking at the I2C protocol and understand there are 4 Modes: Master->Transmitter Master->Receiver Slave->Transmitter Slave->Receiver All communications ...


6

In fact, you can, but you are unlikely to enjoy it as it will be fairly slow. While this module is intended for serial communications - which the ATmega won't support until it has a bootloader on it - the chip around which it is built can also be operated in "bitbang" mode: http://www.ftdichip.com/Support/Documents/AppNotes/AN_232R-...


6

As I turns out, the avr-gcc (GCC) 4.9.1 goodies weren't being used at all! The arduino package was using a decrepit version of gcc, prakhar@sim74stic ~ $ /usr/share/arduino/hardware/tools/avr/bin/avr-g++ --version avr-g++ (GCC) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO ...


6

The basic syntax of C and C++ is very similar, to the point that C code can typically be compiled directly as C++. You'll also find C standard functions (such as printf and malloc) can be used from C++ programs. The major difference in the core language is that C++ has a lot of extra stuff such as classes and templates. Conventionally, C++ also has a huge ...


6

It's no different to working with Make and any other form of GCC. Just set your CC variable and CFLAGS variable accordingly and work as per normal. For instance, I just knocked this one up: CC=avr-gcc OBJCOPY=avr-objcopy CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega328p PORT=/dev/ttyACM0 led.hex: led.elf ${OBJCOPY} -O ihex -R .eeprom led.elf led.hex ...


6

Sure - here's a Hello, World program that uses printf(). Everything that mentions "uart" is what connects printf() to your output stream. uart_putchar() does the actual outputting to ... someplace. That's what you'd modify to direct the C standard output to a different device - SofwareSerial, for instance: // Hello, World program using printf() #include &...


6

The Arduino core libraries (which are nothing more than a bunch of C/C++ files - there is no such thing as the "Arduino" programming language), are compiled along with your source code. These files include all of the initialisation routines and function definitions for things like digitalWrite and so forth. There is a main.cpp file that gets compiled which ...


6

I don't think it is supposed to. The Digispark briefly connects in "bootloader" mode, which you spotted as "Vendor-Specific Device:". Then after 5 seconds it runs the loaded sketch. If your sketch doesn't create a USB port (eg. a keyboard) then it will disappear from the USB list. See: http://digistump.com/wiki/digispark/tutorials/connecting You don't ...


6

You did not specify what Arduino board you are talking about. It would have been useful to tag the question with the appropriate board name. In the following, I assume you want something similar to an Arduino Uno, i.e. an ATmega328P at 5 V and 16 MHz. I realize I can go look up the actual design itself [...] You should. There really isn't that ...


6

i=i++; //increment by one The result of the above statement is not defined. That is, it is not necessarily "i + 1". See: http://en.wikipedia.org/wiki/Sequence_point http://c-faq.com/expr/seqpoints.html Instead use: i++; Or: i = i + 1; A note about "undefined behavior": http://en.wikipedia.org/wiki/...


5

"sleep()" is not a function on arduino. The sleep.h file contains functions for the hardware sleep functionality used to reduce power consumption when processing isn't necessary. "delay()" is the right thing to use. AVR only has one thread, and so there is no meaning to pausing execution by deferring to another thread. Hardware interrupts will always ...


5

Yes, it is possible. Note that the FTDI chip (assuming that is what you have) can be accessed as either Virtual Com Port VCP or D2XX. Where VCP is the traditional method of using them as Serial Ports with avrdude calling "-c arduino -P COM3 -b115200". However the later D2XX method allows for the pins to be Bit Bang'ed. One can see in this tutorial it is ...


5

just to add to the list - some cheaper boards use CH340 chipset here is a blogpost on how to install the drivers on OSX http://javacolors.blogspot.ie/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html From that post: You can find drivers for this chip on the web site of the chinese manufacturer, here : http://www.wch.cn/downloads.php?name=pro&proid=...


5

The components are necessarily going to be proprietary. There is no feasible way around this. If you wanted to design a new open source microcontroller from scratch with no proprietary components, it would set you back several billion dollars. The software used to design integrated circuits costs hundreds of thousands of dollars to license and represents ...


5

It depends on what your processor is doing while it has no real work to do: If you put it to sleep, then yes, using floats will keep the CPU awake for a longer time and burn more energy. If you are instead doing busy-waits (e.g. with delay()) it should make no difference, since the CPU is busy 100% of the time anyway. Update: According to your update, it ...


5

First, let's make this clear: The Arduino environment does not provide a “simplified language”: it provides a simple hardware abstraction layer through its core library. The language is plain C++. Like Talk2, I don't have good book recommendations. The basics of low-level programming are covered in the Arduino tutorial on port manipulation[]. Past this you ...


5

You are misunderstanding what an overflow interrupt is. That is called when the timer overflows (ie. it reaches TOP which in the case of an 8-bit timer is 255). Since you are counting to 124 that will never happen, and thus the interrupt will not fire. You want the "compare A vector" which is called when the "A" register compares to the limit. Example code: ...


5

Basically *.ino is *.cpp without headers. So you can rename it to *.cpp, If you have any functions which are used before they have been defined, provide declarations for each function before its first use #include <Arduino.h> on the top #include <Wire.h> if you are using Wire and so on and you have "normal" CPP file. If you are making ...


5

In the Arduino IDE do this: File > Preferences > Show verbose output during: > upload (check) > OK Tools > Burn Bootloader After it finishes examine the output in the black console window at the bottom of the Arduino IDE window. If you look carefully you'll see that the Arduino IDE actually runs two separate AVRDUDE commands when you Burn ...


Only top voted, non community-wiki answers of a minimum length are eligible