We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

41

There is a bug in the wdt_reset() library routine. Here is the code... __asm__ __volatile__ ( \ "in __tmp_reg__, __SREG__" "\n\t" \ "cli" "\n\t" \ "out %0, %1" "\n\t" \ "out %0, __zero_reg__" "\n\t" \ "out __SREG__,__tmp_reg__" "\n\t" \ : /* no outputs */ \ : "I" (_SFR_IO_ADDR(_WD_CONTROL_REG)), \ "r" ((uint8_t)(_BV(_WD_CHANGE_BIT) |...


23

You most certainly can. According to the datasheet, the watchdog timer can be setup to reset the MCU or cause an interrupt when it triggers. It seems you are more interested in the interrupt possibility. The WDT is actually easier to setup than a normal Timer for the same reason it is less useful: fewer options. It runs on an internally calibrated 128kHz ...


19

According to your simulations, your addressing scheme works fine as long as only uncertainties in resistor values are considered. It's the uncertainty on the voltage that makes it fail. My advice is to cancel out the fluctuations on VCC by using it as a reference to the ADC. You can do so by programming the REFS bits in the ADMUX register, as explained in ...


19

It looks for all the world like an Atmel AT24C16B, a 16kbit two-wire serial EEPROM chip. In particular, page 14 of the datasheet has this diagram explaining the markings on the DIP version of the chip: Seal Year | Seal Week | | | |---|---|---|---|---|---|---|---| A T M L U ...


18

I actually think a better practice that avoids this architectural ambiguity is to include <stdint.h> then use declarative types like: uint8_t for unsigned 8-bit integers int8_t for signed 8-bit integers uint16_t for unsigned 16-bit integers uint32_t for unsigned 32-bit integers and so on...


16

Setting REFS[2:0] to 0bX00 will use VCC as the voltage reference, and setting MUX[3:0] to 0b1100 will use the internal bandgap voltage as the voltage to measure (see §17.13 from the datasheet). From there, the full range of 1023 will tell you what VCC is in relation to the bandgap voltage. So take (1.1*10*1023=) 11253 (or an appropriately scaled ...


12

The ATtiny does not have a hardware multiplier, but software multiplication is not quite as expensive as you imply. See the AVR200 application note and associated code for some optimized multiplication and division routines. Sine and cosine calculations can be accelerated using lookup tables, effectively trading memory space for processor cycles. However, ...


12

A-grade AVRs (and as of November 2014, B-grade AVRs) are minor improvements over the previous iteration; these improvements vary from chip to chip, e.g. the difference between ATtiny2313 and ATtiny2313A is different from the difference between ATmega128 and ATmega128A. Atmel has application notes that explain the difference. AVR531: "Migrating from ...


12

Deeper interpretation: The PLL is actually producing clock cycles during that whole time. The problem is that until it achieves "lock", the clock cycles may at times be too short to allow the CPU to operate correctly, as the VCO control voltage swings both above and below the target value before settling down. So what this specification is really telling ...


11

You should be using a bitwise AND. The expression in the first while loop evaluates to zero, which causes the compiler to remove the loop altogether.


11

The RC oscillator of the ATtiny26L can be programmed to run at 1.0, 2.0, 4.0, or 8.0MHz directly without running through a prescaler. Its PLL will still perform a 64x though, so make sure it is disabled if the device must be eligible for the exemption.


11

Incorrect 16 bit register access pattern When ADCL is read, the ADC Data Register is not updated until ADCH is read. In C, the evaluation order of the | operator is undefined, so this code is could be reading ADCH first, and then reading ADCL. Once you read ADCL then you have locked the data register until the next pass though the loop, which is ...


11

First, in the ATtiny25/45/85 datasheet, page 161, it suggested that there's a internal pull-up resistor between 30 kΩ - 60 kΩ on the RESET pin. It means the MCU will almost always work for a hobby project. However, if the requirement is high reliability, I need to make sure that my ATtiny does not reset unexpectedly. Then you have to put external EMI/...


10

Those modules basically make the receiver pin wiggle in response to how you drive the transmitter pin. They know nothing about what you think wiggling the pin means, and don't contain a UART. More details weren't immediately obvious without digging. That's your job, so I didn't bother to go further. You should provide a link to the datasheet, not the ...


10

From the ATtiny85 Datasheet: The mode of operation, i.e., the behavior of the Timer/Counter and the Output Compare pins, is defined by the combination of the Waveform Generation mode (WGM0[2:0]) and Compare Output mode (COM0x[1:0]) bits. The Compare Output mode bits do not affect the counting sequence, while the Waveform Generation mode bits do. ...


10

If I was to fully test each MCU for its correct functionality, I would build a test board for each, with an adapter or socket to aid the easy change of the IC. Connect each IO pin to a visual output such as an LED, and program it with a simple firmware that will test each pin in turn. A further step would be to test the communication and other features ...


10

I suspect you have set the controller's fuses to use an external clock source as it is impossible to get the internal oscillator to run at 20MHz. You can blow new life into your controller by connecting a clock signal to pin 2 CLKI and try to reset the clock to 8MHz internal RC clock. There is actually a 'fixed' version of ArduinoISP that has a clock output ...


10

Update: To better answer the question, ATTiny's can do anything that don't require hardware the ATTiny's are missing, which include the hardware serial port, hardware i2c, or multiple interrupts. Since this is hidden away in the Arduino Libraries, unless you have a good understanding of how they work or read the actual library files, things like the Wire ...


10

Take a look a the micronucleus bootloader... https://github.com/micronucleus/micronucleus It allows an ATTINY to accept a code download over a (slightly hackey) USB connection. It is widely used and well supported. Here is an example of the hardware that uses only a handful of passives to add a minimal USB connection to an ATTINY... From the excellent ...


8

The more-or-less standard definition of a byte in C is 'unsigned char'.


8

If it's a general purpose USB "charger", then it should be fine. Since those don't know what device will be hooked up, they have to provide regulated 5 V as USB devices expect. If it's a charger for a specific device, then it might play some games, but even then likely not. You can always check this. Use a voltmeter to read the output power voltage. ...


8

"text" is actually code flash size, not SRAM. There are several problems here: 1) The "print" function pulls in a large amount of code for formatting format strings. This is dumb. The '85 only has 8 kB of flash total, compared to the 32 kB of the Arduino Uno. 2) The String class uses both some amount of code space, AND a lot of SRAM. The '85 only has 512 ...


8

Interesting. I'd assumed it was a piezo for a moment. Then the datasheet said otherwise. Actually, it's quite similar to some cheap earphones they used to make -- circular, very thin disk of metal over the top of a circular magnet with a coil present. It'll work over a modest audio range. (I used to dismantle them to see how they worked when I was a kid.) ...


8

A minimal software PWM could look like this: volatile uint16_t dutyCycle; uint8_t currentPwmCount; ISR(TIM0_COMPA_vect){ const uint8_t cnt = currentPwmCount + 1; // will overflow from 255 to 0 currentPwmCount = cnt; if ( cnt <= dutyCyle ) { // Output 0 to pin } else { // Output 1 to pin } } Your program sets dutyCycle to the desired ...


7

You can use these macros that get defined automatically when you include <avr/io.h>: SIGNATURE_0 SIGNATURE_1 SIGNATURE_2 For ATmega1280, they're defined as: /* Signature */ #define SIGNATURE_0 0x1E #define SIGNATURE_1 0x97 #define SIGNATURE_2 0x03 in iom1280.h (which is automatically included through <avr/io.h> when you compile code for the ...


7

Yes, you can manually write default data to EEPROM in the source code. First, check out this awesome guide on the EEPROM with AVR: Dean's AVR EEPROM Tutorial. Also, I should add that it is a better idea to create a .eep file containing the EEPROM data using the makefile which will be programmed to the device along with the source code. However, if you are ...


7

With avr-gcc the EEMEM macro can be used on the definition of a variable, see the libc docs and an example here: #include <avr/eeprom.h> char myEepromString[] EEMEM = "Hello World!"; declares the array of characters to reside in a section named ".eeprom" which after compilation tells the programmer that this data is to be programmed to the EEPROM. ...


7

Follow the steps in this post to check your RAM usage: Checking memory footprint in Arduino My guess is that you have gone over as the RAM size of the ATTiny85 is 512 bytes. In your sketch, font will be stored in RAM. You want to store it in the FLASH program memory. Follow these instructions to do so: http://www.arduino.cc/en/Reference/PROGMEM


7

Your problem comes from the use of the LM35 temp sensor. You try to use that instead of a more appropriate choice, which causes you to include more circuitry. Replace it by a sensor that works at 3V (LM75 clone? NTC?) and you can use a single LiSOCl2 cell... If you also select a uC that works down to ~ 2.5V you can use two AA cells if you really want to ...


7

It's possible you could reflow this tiny BGA onto a gold-plated PCB (flux only, no paste) with a toaster oven approach, but your yield may not be 100% on the first try. It has to be placed within 0.1mm or so (they say +/-0.03mm for production) so a microscope would be a good idea unless your eyes are a lot better than mine. There's not a lot of advantage ...


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