Hot answers tagged

11

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);


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

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 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

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

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

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 ...


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

shiftOut() relies on digitalWrite(), which is dead slow by AVR standards. You could probably get a factor 5, or even 10, by reimplementing shiftOut() using direct port access instead. Using SPI (as suggested in the comments) would be even faster, but you would need to clock out of pin 13. Edit: here is an attempt at such implementation. Note that it is ...


5

It's not just Pin 2 that can wake from sleep. Depending on which sleep mode you are in different interrupts (both internal and external) can wake the chip up. The datasheet contains this helpful table: The external interrupts (pins 2 and 3 on the Uno, and only "Level" trigger mode), pin change interrupts, I2C address matching, and the watchdog are the only ...


5

No. First, mmap() makes almost no sense on an AVR, as there's no memory management unit or concept of process memory to configure. Some related concepts like sbrk() are occasionally implemented in a minimalist fashion to let library functions designed for larger computers work, but they typically only update a tracking variable or fail. For things that ...


5

Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory. https://majek.sh/en/writing-to-internal-flash-on-arduino/ The number of times you rewrite a cell are limited. I'd suggest you are better off with adding a FRAM memory chip. Get a 5V part with SPI interface. Fast reads,...


4

You can make adapter boards (one for each mcu model). The bottom side (male headers) would plug to the breadboard and the upper side would have female headers with the same pinout as an Arduino board (female hearers placed in the appropriate positions to match Arduino shields). Such a board shouldn't be difficult to design. Here is an image that resembles ...


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