55 votes

MCU programming - C++ O2 optimization breaks while loop

The code optimizer has analyzed the code and from what it can see the value of choice will never change. And since it will never change, there's no point in ...
user avatar
55 votes
Accepted

Why do we need a bootloader separate from our application program in microcontrollers?

A bootloader on a microcontroller is responsible for updating the main firmware over a communication channel other than the programming header. This is useful for updating firmware in the field over ...
user avatar
  • 955
55 votes
Accepted

Why do microcontrollers need a programmer device?

That's what the programmer does. It takes the binary output from the compiler and stores it in the MCU's Flash EPROM, usually over a serial bus. Flash EPROM requires a programming algorithm to store ...
user avatar
  • 18.5k
36 votes
Accepted

Create Circuit Simulation

I wrote the simulation engine that powers CircuitLab from scratch: from the sparse matrix library up through component models and simulation modes. My co-founder wrote the front-end. It ended up being ...
user avatar
  • 3,389
32 votes

Why do microcontrollers need a programmer device?

A programmer is the implementation of " via specific bus,". Some devices have inbuilt bootloaders (may be hardware or software or firmware) that allow the use of a port of some sort to load ...
user avatar
  • 143k
31 votes
Accepted

STM32 & ST-LINK - Cannot connect to MCU after successful programming

I managed to solve that problem. If anybody encounters similar problem, here's what I've done: I used ST-Link v2 and ST-Link Utility. In setting, I set "Connect under reset" and SWD ...
user avatar
  • 1,537
30 votes

Is it possible to draw circuits through code?

If you are familiar with \$\LaTeX\$, you can use circuitikz to draw nice circuits by writing code. Example. More Examples
user avatar
  • 8,177
26 votes

Do Electrical Engineers use microcontrollers?

Q: Do Electrical Engineers Use Microcontrollers? Yes. Absolutely. From simple toys to complex manufacturing processes and robots. It is not a skill that will hurt you to know. Learn as much ...
user avatar
26 votes

Why do we need a bootloader separate from our application program in microcontrollers?

So that the loading process can recover from errors. Suppose there is a communication error or power disconnects during an upgrade. If the boot loader were part of the application you were upgrading ...
user avatar
  • 10.2k
22 votes
Accepted

Inbuilt flash memory size not enough

You cannot extend the program memory (flash). TI produces the same chip with double the flash and RAM, but nothing else changed: TM4C1230D5PMI. If you cannot use a chip with larger flash, you will ...
user avatar
  • 1,132
22 votes

How can I estimate the speed of this code section for this microcontroller?

Since the code snippet you're interested in isn't big, you could disassemble your compiled code, look at all the assembly instructions and count how many cycles they need. You can find the number of ...
user avatar
  • 713
21 votes

ICSP or Pre-Programmed Microcontroller

If you have the space for a header, that's probably the best option, and the slightly staggered pins Majenko recommends is a good way to hold a connector in place without adding complexity. But here'...
user avatar
  • 66.1k
21 votes

Why do microcontrollers need a programmer device?

transfer it to specific place in flash memory via specific bus This is exactly what flash programmer devices do. They just don't use something slow and archaic like RS232, but instead nowadays ...
user avatar
  • 14.3k
20 votes
Accepted

What does a function mean that doesn't have "void", "int", etc in front of it mean?

The functions are interrupt handlers, defined using the ISR(vector, attributes) macro. The macro generates a proper platform-specific function signature, including ...
user avatar
19 votes
Accepted

ICSP or Pre-Programmed Microcontroller

I would suggest always including a header in that kind of quantity (small). If you get to larger quantities you can consider pads for pogo pins (you'd have to make a fixture to hold the PCB in ...
user avatar
18 votes
Accepted

Do you typically need to program-in a USB communication protocol?

Like any protocol stack, USB incorporates components representing various layers. High-level drivers and libraries provide higher-layer functionality on top of lower layers, effectively abstracting ...
user avatar
  • 14.5k
16 votes

Can an operational amplifier circuit be made entirely out of diode Nand and Nor gates?

Can An Operational Amplifier Circuit Be Made Entirely Out Of Diode Nand And Nor Gates? This apparently simple-enough question is somewhat ambiguous and can be answered several ways. Spehro has ...
user avatar
  • 143k
16 votes

Is it possible to drive a 2 X 16 LCD display using logic gates? (Without computer)

It is possible to make a circuit out of logic gates that would be able to initialize and display characters onto a 16x2 LCD character mode module. It is also possible to make a circuit out of logic ...
user avatar
15 votes

Does each microcontroller line have its own programming language/syntax?

The language in this case is exactly the same. The Arduino environment happens to have some extra libraries (just more C code) that 'wrap' the access to the actual hardware registers (DDRx, PORTx, ...
user avatar
15 votes

Is it possible to draw circuits through code?

Check out SKiDL (https://github.com/xesscorp/skidl), this is along the lines you're thinking. Edit (as req'd): SKiDL allows procedural description of all circuits (rather than just digital), instead ...
user avatar
  • 7,309
14 votes

ICSP or Pre-Programmed Microcontroller

I always add space for an ICSP header, even if it's not populated. I have three ways of doing it at the moment depending on situation. One of my designs has a very fine pitch header for which I have ...
user avatar
  • 55.5k
14 votes
Accepted

Is the datasheet of the AVR ATmega32 wrong?

If the system clock is 16 MHz and the prescaler is 256, you timer will run on \$ \large \frac{16\,MHz}{256} = \small 62500\,Hz \$ , so there will be an increment in every \$ \large \frac{1}{62500\,Hz} ...
user avatar
14 votes

How can I estimate the speed of this code section for this microcontroller?

Let's do it! Say we have the code ...
user avatar
  • 330
13 votes

Is it possible to draw circuits through code?

Many programs can draw a schematic. None that I know of can draw a good schematic: One that emphasizes the most important information, and arranges the circuit in a clear and easy to understand way. ...
user avatar
  • 121k
13 votes
Accepted

MCU programming - C++ O2 optimization breaks while loop

(Cross site duplicate on SO about the thread case, rather than interrupt/signal-handler case). Also related: When to use volatile with multi threading? A data race on a non-...
user avatar
  • 1,279
13 votes

PIC12F675 GP4 doesn't work

You have configured the PIC to output the internal clock signal on GP4 using #pragma config FOSC = INTRCCLK Replace INTRCCLK with INTRCIO.
user avatar
12 votes

Do Electrical Engineers use microcontrollers?

This particular job may not, but the product would likely include a microcontroller and perhaps be controlled by a more powerful embedded system. Note that it mentions 'troubleshooting' (but not ...
user avatar
12 votes

How come Misra C checker is such a prestigious tool?

A MISRA-C checker is much more than just a style checker; it enforces a set of software development guidelines for the C programming language developed by MISRA (Motor Industry Software Reliability ...
user avatar
  • 47.1k
12 votes

FPGA - DIY Programming

Yes, it would work just fine. Actually, the development tools for most FPGAs allow you to program the external flash directly through the FPGA's own JTAG connection, eliminating the need for a ...
user avatar
  • 165k
12 votes
Accepted

PIC12F675 GP4 doesn't work

Just to add to Spehro's correct answer: Since the microcontroller you are using has only 8 pins, they necessarily must share functionality to provide the various features that the device is capable ...
user avatar
  • 27.8k

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