Hot answers tagged

64

Other answers cover your question pretty well at an abstract level (hardware), but having actual experience with the GBA in particular I figured a more detailed explanation may be worth while. The GBA had many drawing modes and settings which could be used to control how the graphics processor interpreted the video RAM, but one thing was inescapable: the ...


48

I'm not going to sugarcoat this; it's pretty bad. This project seems far too difficult for someone with your experience level. I recommend doing something simpler first to build up your skills. Try a basic microcontroller project to get familiar with the design/layout/soldering process, then move on to a simple wireless project, then maybe consider building ...


42

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


35

Most micro controllers these days have part or manufacturer specific methods to protect the embedded firmware code. This is generally done by locking out the circuits that normally allow the code memory to be read out. (You'll have to look for part specific details in the data sheet or at the manufacturers web site in applicable application notes). Once ...


30

One very good reason, as I learned myself from a recent prototype, is reversing the physical layout of the IC in a circuit. I plugged a through-hole version of this microcontroller into a socket backwards, and spent about an hour with an oscilloscope trying to determine why pins were not behaving as expected. When I discovered the IC was in backwards (and ...


24

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


23

Pointers are pointers. That is what they are. They aren't treated differently at all (how could you treat them differently?) The main differences between X86 and AVR are: AVR is 8 bit, X86 is 32-bit (or 64 bit for x86_64), so pointers are a different size. The AVR is Modified Harvard architecture, so there is more than one address space, so you have to ...


23

If nothing else is running in the MCU, then you are free to take as long as you like in the ISR. But, this is a bad habit to get into, and it means that if you want to do anything else, you'll likely have to rework the code. A particular case is if the MCU is using a serial library, that expects interrupts to be working often enough to service individual ...


21

I felt the need to give a non-blocking solution to the problem especially because we are talking about twelve hours of delay here. The util/delay.h library and its _delay_ms() and _delay_us() functions are the software delay functions. They are convenient in small programs and for quick prototyping and experimentation. They are simple and the accuracy ...


21

The key feature of all the games consoles that distinguished them from early PCs and virtually all home computers(1) was hardware sprites. The linked GBA programming guide shows how they work from the main processor point of view. Bitmaps representing player, background, enemies etc are loaded into one area of memory. Another area of memory specifies the ...


21

Assuming that you want to optimize for speed: Unless you really find out how many cycles it takes if you use mul, you can't compare. So let’s try: If you use the mul instruction, you need two of them (the operand is 16 bit). So that already costs 4 cycles. You have to load constant 10 into one register: 1 cycle. Then you have to add both 16 bit results. ...


20

Short answer: your registers are 8-bit and your values are 16-bit. It's therefore handling them in two pieces. Long answer: ldi r24, 0x01 ; 1 ldi r25, 0x00 ; 0 Store the 16-bit value 1 in 8-bit registers r24,r25. std Y+2, r25 ; 0x02 std Y+1, r24 ; 0x01 Store it at stack locations Y+1, Y+2. ldi r24, 0x02 ; 2 ldi r25, ...


20

There is a de facto standard way to do this (assuming C programming): Interrupts/ISRs are low-level and should therefore only be implemented inside the driver related to the hardware that generates the interrupt. They should not be located anywhere else but inside that driver. All communication with the ISR is done by the driver and the driver only. If ...


20

There are interrupt vectors for both RXC and TXC (RX and TX complete) on AVRs. You should never have to poll for these unless you want to. AVRFreaks has a nice post on this, and so does the manufacturer.


19

"My question is - how did a device like the GBA achieve a frame rate of nearly 60fps?" To answer just the question, they did it with a graphics processer. I'm pretty sure the Game Boy used sprite graphics. At a top level, that means that the graphics processor gets loaded things like an image of a background, and an image of Mario, and an image of ...


19

There have been repeated attempts to create various different auto-generating code for the last 20-30 years or so. Each time, it's marketed as something revolutionary, but it never becomes a success. This isn't something new at all. Siemens/Infineon had such tools way back in the late 1990s. Motorola/Freescale also attempted something similar in the early ...


18

Mainly, it has to be connected because the manufacturer says it should. Aside from that, they should for full operation of the chip (all ports/pins), to prevent floating pin issues on the AVCC side, to prevent noise on the digital side. There are issues where leaving the AVCC side unpowered causes parasitic power draw and can destablize the internal clock, ...


18

If the AVR or any MCU has a way to output the clock to an external pin, even if it divides it down, I would measure that pin. Measuring at a clock pin will interfere with the clock frequency due to capacitance of the scope probe. This way it’s buffered.


18

Digi-Key has a broad search tool where you can select parts across 30 microcontroller manufacturers. It has ARMs, AVRs, PICs, 8051 derivatives etc. -- over 48,500 individual parts. (Click for a larger view) You can search for core size (8, 16, 32), speed, peripherals, program size, RAM size, EEPROM size, # of I/O pins, and package across all parts.


18

Even though the Motorola 68000 and the Sega Genesis are quite old (early 1980's), you are not going to find a low-end (i.e. 8-bit) AVR that can emulate the entire game machine. The Sega Genesis ran at 7.61 MHz and had 72KB of RAM (plus an additional 64KB of video RAM). However the game programs resided in ROM, so you will need additional RAM to hold them (...


18

Yes, it is safe to abruptly shut off an Arduino. Well, mostly safe. The processors used in the various Arduinos have three types of memory: Flash - Where your program is stored. Your program can read stuff from here, but cannot write it. RAM - Where your program variables are kept while the program in running. The data here disappear when you turn the ...


18

As others have said, you shouldn't have a problem as long as you double check your code. If you do get it wrong, by and large the ATMega IO pins will limit themselves to about ~80mA due to internal resistance of the MOSFETs (value found by experiment). This is not good for the chip, but as long as you don't leave it in this condition for an extended period,...


18

It means that the ALU in the microcontroller has a hardware multiplier, which takes two instruction clock cycles to perform a calculation. This is faster than doing multiplication using software (e.g. adding multiple times in a for loop).


17

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


17

Before you start thinking about switching, make sure you have a good solid design. You need to start thinking about all the ways you could have problems in your design. A good way to do this is to stop thinking about a microprocessor as a "magic box" that you put code into and does what you tell it to and start thinking about how it functions, on a gate ...


17

The main purpose of a bootloader is to allow updating the firmware through interfaces other than the default hardware interface. For example, this allows updates via communication channels that the application uses otherwise for its own purposes, which means that you can do remote in-system updates without requiring physical intervention at the remote site. ...


16

PA0 will be defined as 0 so the following line: DDRA |= (1 << PA0); Equates to shifting 1 left by zero bits, leaving an OR with the value 1 to set the first bit. Whereas the following line: DDRA |= PA0; Is doing an OR with zero so won't change the registers at all.


16

The datasheet link you provided was for the shorter summary datasheet. You need to look at the complete datasheet to get the comparator propagation delay. http://www.atmel.com/Images/Atmel-42734-8-bit-AVR-Microcontroller-ATmega48PA-88PA-168PA_datasheet.pdf On page 384 the analog comparator propagation delay (the time delay between a change in the ...


16

You may be interested in EEVBlog's video about powering an MCU without connecting the power pins. If you drive the I/O pins on the MCU, you may end up powering up the MCU through its protection diodes. If, after the diode drop, your VCC ends up being below or above the minimum voltage required to drive your MCU (or draw more current than the internal ...


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