Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

AVRSIDE-free alternative IDE for WINAVR

Author (Jurek Szczesiul) of AVRSIDE program decided that there is not enough functionality with standard Programmers Notepad. He started to write his own IDE, which expands functionality and usability. Project is still in development stage but looks very promising. Main features are: SDI interface model with as much space for code as possible; creating single/multifile projects; compile and make / build operations available; makefiles edition – directly set options you need; compilation log file creation; different syntax highlighting for C and ASM; jump – to – error makes easy code cleaning; avr – gcc assembler code preview for single file and whole project; multi file project import from any folder; auto creating dependencies for header files; libraries manager; simple symbols browser; code templates and avrlibc functions auto-completion; automatic hint for function declaration number of searching tools; embedded ISP interfaces based on com port and USB. Project page of AVRSIDE. Download AVRSIDE from here.

Continue reading

Function calls and stacking of parameters in embedded systems

Usually when you write C programs for microcontrollers you use functions that can be called any time in main program or in another function. Compiler compiles these functions as subroutines. These functions can be called from main function or from other functions – this is called nesting (nested subroutines). If you see the listings of compiled program you will see that subroutines are called by using call or rcall keyword. The argument of this instruction is an subroutine address which will be executed on the next processor cycle. Call instruction also writes return address from function to the stack to continue program after returning from function. The next instruction begins execution at the start of the subroutine and returning from function is done after ret instruction which also restores an address of program counter in hardware level. Stack is also used to store all arguments of function – it usually depends on compiler hos it is done. But in general compiler generates code which: Push all arguments to stack; Call the function; Allocate storage for all local variables in the stack; Perform the function; Deallocate local variables from stack; Return from function; Deallocate the space used by arguments. All these…

Continue reading

Build Piconomic Atmega128 development board by yourself

Earlier I have written about Piconomic learning course and its nice development board they provide. You can purchase the board if you are from a South Africa internationally for $49.99 + $9.37 airmail shipping with a tracking number, which takes 2-4 weeks, depending on customs delays. Of course, there is an excellent opportunity to build this board by yourself. They allow building a development board for free only for personal use by using their Protel 99 SE project files. So I decided to make one and now it is standing on my table and blinking blue led. First of all I have ordered to make PCB by using milling-drilling plotter. Of course I could make board by myself, but i wanted to save some time and nerves in case of errors. After one week my board was shipped to me: Then I bought all parts needed. Just one thing that didn’t go well was that I couldn’t get capacitors and resistors in SMD packages 0603, so I used 0805 lied on side. It doesn’t look very OK but works. Presently I have checked the Piconomic project logs and found out that they improved the board layout files by exchanging all…

Continue reading

Build your own RS232 adapter with LED indicators

After I have made simple RS232 adapter I have decided to improve it a little bit and added status LEDs of TXD and RXD lines. This adapter works with my AVR development board and should work with any TTL level UART interface. Unit is powered from target board using power pins. The circuit: And PCB: After putting board in to the plastic case: TXD and RXD lines are high level while idle – this is why LEDs are ON. During data transmission LEDs are blinking. Download project RS232 adapter Eagle files.

Continue reading

Generate sine wave modulated PWM with AVR microcontroller

This example will show how ease can sinewave modulated PWM modulated using AVR microcontroller and a few lines of code. For this example, I used Atmega8 MCU. All project is set up in VMLAB simulator. To achieve this, I saved sinewave lookup table in a Program memory (don’t forget to include interrupt.h header file): const uint8_t sinewave[] PROGMEM= //256 values {0x80,0x83,0x86,…}; PWM is generated by using Phase and frequency correct PWM using a 16-bit timer in Atmega8. Modulation is done by updating OCR1A value with one from sinewave table each time when compare matches. Reading from flash program memory is done simply: OCR1A=pgm_read_byte(&sinewave[i]); The line above is placed inside the output compare interrupt for OCR1A service routine. Resulting signal in scope simulator: Download project Sinewave modulated PWM source code if you want to try it by yourself. This way you can modulate PWM with any signal shape that is stored in the lookup table. Updated AVRStudio4 project files!

Continue reading

Variables in embedded C programming language

What are variables in C language. Variables are simple keywords which are defined by the values. Values can be changed. Variables are like a boxes with some size where values like apples can be put in. So variables can be various forms and sizes so called variable types. Variable type is defined by a reserved word which indicates the type and size of variable identifier: unsigned char my_char; long int all_my_numbers; int number; Why do we need variables? The basic answer is that memory is limited and compiler needs to know much space to reserve for each variable. The coder needs to specify the variable type and its size by using one of reserved words from the table:

Continue reading

Two AVR-GCC examples of using AVR 8 bit Timers

Timers are an essential part of microcontrollers. They can be used in many areas starting with simple timed routines to RTOS. The good thing is that timers run independently to the main program flow. Set up the timer counter and let it do its job while your main program runs and does its job. Let’s take AVR Atmega8 microcontroller. It has two independent 8-bit timers. One is a little simpler which is featured with essential functions like: Single channel counter; Frequency generator; External Event counter; 10 – bit clock pre-scaler. Another is more advanced where is OCR (output compare register) included, which allows implementing PWM routines. It has the following features: Single Channel Counter Clear Timer on Compare Match (Auto Reload) Glitch-free, phase Correct Pulse Width Modulator (PWM) Frequency Generator 10-bit Clock Pre-scaler Overflow and Compare Match Interrupt Sources (TOV2 and OCF2) Allows Clocking from External 32 kHz Watch Crystal Independent of the I/O Clock Datasheet documents these timers pretty well. Let’s view a couple of examples with both 8-bit timers. The first example is to do simple task – every time timer overflows it has to increase variable value by one. And this variable is sent to PORTB in…

Continue reading