AVR-DDS signal generator in-line ASM explained

I have got a couple of questions (in fact, not the first ones) for the AVR DDS generator I have built: “that’s all the asm code that I don’t understand. Could you explain it? Is it possible to do it with inline asm (only in C)?” I decided to explain this part more deeply because it took me to figure this all out. First of all, what we have to do, it is to implement simple DDS algorithm. In a few words, Direct Digital Synthesis(DDS) is known as a Numerically Controlled Oscillator. Simple rule: NCO-based DDS is a point(memory location)-skipping technique (and a constant interpolation of the stored signal) and runs at continuous update(clock)-rate. As the DDS output frequency is increased, the number of samples per waveform cycle decreases. Practically speaking, let’s have some math. We have a clock generator connected to MCU. In my case, F_CPU=16000000Hz. This is our Clock In.

Continue reading

ARM7 exception modes

This is an important part of understanding ARM operation modes and handling them. ARM7 supports seven types (0x00000014 address is reserved) of exceptions: As you can see in the table, each exception has its own name and fixed address, so-called exception vectors. When an exception occurs, execution is forced from a fixed memory address corresponding to the type of exception. When an exception occurs, R14 and SPSR registers act like this:

Continue reading

ARM7 MCU registers

ARM has 31 general purposes 32-bit registers where 16 of these are visible at any time. Other registers are used to speed up the processing of exceptions. There also are 6 32bit wide status registers. Let’s see how it looks like. Registers are arranged in partially overlapping banks with a different register ban of each MCU mode. As I mentioned, 15 general-purpose registers(R0 to R14) and one or two status registers and PC are visible at any time. Basically, R0-R12 registers are user register, that doesn’t have a special purpose. Registers R13 – R15 has special functions. R13 is used as stack pointer (SP), R14 is used as link register (LR), and R15 is as the program counter (PC):

Continue reading

Alternatives of MAX232 in low budget projects

Sometimes when you work on low-budget projects or don’t want to go shopping for max232 or similar IC, you can save your time and money by using other TTL to RS232 converter. We usually used to use a MAX232 chip like this: Max232 IC is a specialized circuit that makes standard voltages as required by RS232 standards. This IC provides the best noise rejection and very reliable against discharges and short circuits. If your project is more advanced and has to reliable you must use specialized RS232 to TTL converter IC’s. As I said Specialized is more expensive than other solutions.

Continue reading

Easy H-Bridge on MOSFET IRF7105 transistors

I think I don’t have to explain what is H-Bridge circuit. Well, it is mainly used to drive DC motors that they could be run forward and backward. The circuit is often used in robotics. Usually, there is a need to build a small, powerful, and with good characteristics H-Bridge. One solution is to use IRF7105 p and n channel MOSFET pair coated in the SO8 SMD case.

Continue reading

More about microcontroller oscillators

The choice of the microcontroller oscillator depends on many factors. Before choosing one, you should consider Cost, accuracy, and environmental parameters. Clock sources can be grouped into two major groups: mechanical resonance(crystals and ceramic resonators) and RC (resistor, capacitor) oscillators. The most popular form of mechanical resonant generators in microcontrollers is Pierce oscillators: Ceramic and crystal-based generators provide very high accuracy and low-temperature coefficient. But they have a slower startup comparing to RC generators. But the RC generator’s precision suffers from temperature variations and supply voltage. Nominal frequency can variate from 5% to 50%:

Continue reading

How does ARM7 pipelining works

One of the key features of the fast performance of ARM microcontrollers is Pipelining. ARM7 Core has a three-stage pipeline that increases instruction flow through the processor up to three times. So each instruction is executed in three stages: Fetch – instruction is fetched from memory and placed in the pipeline; Decode – instruction is decoded and data-path signals prepared for the next cycle; Execute – instruction from prepared data-path reads from registry bank, shifts operand to ALU, and writes generated result to dominant register. Pipelining is implemented at the hardware level. The pipeline is linear, which means that in simple data processing processor executes one instruction in a single clock cycle while individual instruction takes three clock cycles. But when the program structure has branches, the pipeline faces difficulties because it cannot predict which command will be next. In this case, the pipeline flushes and has to be refilled what means execution speed drops to 1 instruction per 3 clock cycles. But it isn’t true, actually. ARM instructions have nice features that allow for the smooth performance of small branches in code that assure optimal performance. This is achieved at a hardware level where PC (Program Counter) is calculated…

Continue reading

Connect Nokia 3310 LCD to LPT port

I found this circuit really simple and interesting. It is effortless to drive Nokia 3310 graphical LCD using a simple LPT cable and some PC software. First of all, connect graphical LCD to LPT port according to the following circuit: The graphical display needs about 3.3V of supply voltage, while LPT gives about 4.5 -5V. This is why diodes are used to reduce voltage by the fo犀利士 rmula: Continue reading

Continue reading

High capacity multimedia cards in embedded systems

Multimedia cards are popular around us. There are well known Compact Flash, CD, MMC Memory Stick. Usually, when you make a new design with external memory, you consider EEPROM or Flash ICs with some capacities with up to a few Mb. But why limit yourself? Because in some cases, it is smarter to add a multimedia card socket and use any capacity (even a few Gb) multimedia cards in your projects. Using removable storage cards you get few advantages: You can share data from your card with any device that has a reader; You can have any size of storage memory; Easier to get one than specific IC; Cost-effective; I really like Using multimedia cards because you can get huge amounts of storage of price small EEPROM or Flash IC. They are cheap because of mass production. They are available everywhere: digital cameras, Mobile phones, personal players, etc. Another advantage is that you can store data in a format that the PC understands. This way, it is easy to collect data for later analysis using PC software.

Continue reading

RS-485 interface for connecting multiple devices

RS-485 is an updated version of the RS-422 interface. It is designed to communicate between multiple devices connected to a single data line. Standard allows connecting 32 transceivers to the data line. This is achieved by using tri-stable drivers that are separately programmable. This allows only one device to work at a given time. Resistors used in the circuit are so-called termination resistors for matching the transmitter and receiver impedances to avoid reflections. The matching resistor depends on the cable used but is 120Ohm.

Continue reading