Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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


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


9

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)


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

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


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

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

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


5

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


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


4

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


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


4

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


4

You can use Atmel Studio to write code for the MCU(s) on the Arduino boards. If the IDE itself does not support uploading the code to the Arduino then it is still possible to use AVRDUDE or BOSSA to upload it via the command line.


4

The address you are looking for is a symbol known by the linker. Then you can have the linker put the value of the symbol straight into your code: no need to load from memory. In other words, you use the ldi instruction to load the required address as an immediate value. You should also reverse the order of the struct definition, since you are storing SPL at ...


4

During the creation of this question I found out the answer... Though I wanted to share it with you guys for later reference. It has been quite a time since I have worked with AVR. You should read pins from PINx You should set pins in PORTx Set DDRx to 1 for OUTPUT and to 0 for INPUT ^ This is fun because PIC/Microchip MCU's use 1 for input and 0 for ...


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