About computers, embedded systems, internet, broadcasting, music, science, technology, and other cool stuff.
Tuesday, 1 February 2011
JTAG Cables and Programmers
Thursday, 16 September 2010
Universal JTAG Cable
Every electronic device around has some microcontroller or other programmable device in it. Even kitchen appliances or toy has some kind of electronics which controls important functions. In some cases this electronic device has predefined functionality which can not be changed. But in most cases this electronics contains a processor that uses flash memory to store code. And if a device is programmable then you can change the program it runs at any time.
Of course, in many cases this programming is not needed since the electronics performs what is supposed to. But in some cases it makes sense to allow end users to update the device with the latest firmware. Therefore, it makes sense to have a universal interface that can be used in factory and at home to program electronic devices with simple additional hardware. This universal interface is JTAG. This is a standard that defines a serial interface to transfer data between a device and computer (or between devices). The JTAG interface needs only four basic signals. This makes it easy to use PC parallel port as JTAG interface. While this works many modern JTAG programmers use USB port to connect to the PC.
Another beauty of the JTAG interface is the possibility to connect many devices in chain. This way you can program all the JTAG enables devices on the board with only one interface. In any case you need a JTAG cable to connect to the device. Each device may have own JTAG pinout but this is not a problem since JTAG cables can be made (almost) universal--at least for few device types. Unfortunately, JTAG cable is not enough. You need also a suitable software that will program the target device.
JTAG is not used only for commercial electronics. It is also a standard interface for all embedded systems including FPGAs, microcontrolelrs and various memories. Each manufacturer has some kind of JTAG cable to program their devices. Unfortunately, these cables use dedicated software and can not be used for other purposes.
One of the very popular uses of the JTAG interface in consumer electronics is to reprogram some router models with new firmware. There are many cheap JTAG cables that can be used to bring a new life for an old router. Changing original firmware is very popular not just for routers but also for other highly popular electronic devices. The Xbox is such example where a simple JTAG hack can change some built-in functions.
There are many JTAG cable supplies around. Before you decide for specific cable you need to check the JTAG pinout and software support. Usually, cheap cables are made only for specific devices and use the parallel port signals to program the device. More advanced JTAG cables use USB interface or at least a buffer to boost signals from parallel port.
Friday, 10 September 2010
Popular Microcontrollers
Embedded systems are not just complex projects in electronic laboratories--they are present in everyday devices. Every mobile device, electric toy or kitchen appliance has some electronic board which usually includes a programmable device--microcontroller. This is a special microprocessor with peripheral devices and I/O ports. Depending on the volume of the device the manufacturer can decide whether to develop an ASIC--a dedicated integrated circuit which performs all functions for this device or to make a standard board with discrete components. In both cases some microcontroller is used, either as a soft core in ASIC or a standard integrated circuit.
Popular microcontrollers are popular mainly because of availability of affordable development tools and low prices of devices. When hobby engineers start using one family they get used to it and it is very likely that they will use it later in a professional project. While PIC and AVR microcontrollers are heavily used in hobby projects, ARM has prevailed in the professional embedded world. However, 8051 microcontrollers are still used in many hobby and professional projects.
There is a plethora of choices from open-source projects to various IP cores with significant royalties for each device. Despite this choice there are few microcontroller families that are popular because of their flexibility, powerful development tools or because of historical reasons.
ARM
This is currently the hottest RISC core used in almost all mobile phones, portable devices and many other applications. It has powerful instruction set, low consumption, offers easy integration and there are many good development tools for easy development and debugging. The ARM core is also used in many popular microcontroller families from Atmel, Luminary Micro (now Texas Instruments), NXP and many other manufacturers. These microcontrollers are very popular among embedded engineers and are used in various applications from automotive industry to hobby projects.
AVR
This is one of the most popular microcontroller families from Atmel. It is also very popular among hobby engineers and it is used in many projects from simple LED controllers to complex communication devices. The RISC architecture offers fast execution and low power consumption. Development tools are available for free which is a great bonus for electronics enthusiasts. AVR is a direct competitor to Microchip's PIC. Some favor AVR, others like AVR. There is no clear winner. Both families work well. It is up to the developer/programmer what he like or prefers.
PIC
This is a leading microcontroller family from Microchip. PICs are available in very small packages with only few pins and also as powerful 32-bit microcontrollers with many peripheral modules and I/O pins. They are very popular among hobby engineers--in hobby projects you will find either AVR or PIC.
8051
This is a very old 8-bit microcontroller architecture that has managed to survive for more than 30 years. Many excellent compilers, a lot of code examples and simple development has contributed to the popularity of this family. This core is still used in many modern microcontrollers from Silabs, NXP, Atmel and many other microcontroller manufacturers. It is very likely that the 8051 is the most widely used core in embedded applications. Of course, many new designs will probably use ARM or some other advanced architecture, but because of popularity of the 8051 family in the past and availability of development tools (C, Assembler and Pascal), it is still used in many applications.
Saturday, 21 August 2010
Pascal Compiler For 8051 Microcontrollers
The 8051 core is one of the widely used microcontroller cores. It is about 30 years old and still very popular. Originally designed by Intel in late 1970s, 8051 core found its way into many popular microcontroller families manufactured by Atmel, Silicon Labs, NXP, and many others. One of the reasons for popularity of 8051-based microcontrollers is the availability of many excellent compilers, from freeware applications to high-priced professional development tools.
A very popular programming language is C. It is widely used in development of operating systems, desktop applications and embedded systems. Beside assembly language, C is the most popular programming language used for embedded programming. 8051 microcontrollers are no exception. SDCC is the most popular open-source C compiler for 8051 microcontrollers, while Keil (now an Arm company) makes the widely used and popular commercial development tools for 8051 microcontrollers.
But there are also other popular languages. One of them is Pascal. Named after French mathematician and physicist Blaise Pascal, it was developed by Niklaus Wirth in late 1960s. The main objective of this programming language was to teach programming with emphasis on structured programming. Many schools used Pascal as introductory language to teach first steps in programming. Pascal is considered as a high-level programming language. Algorithms implemented in Pascal need little comment since the statements are composed of English keywords that clearly describe in English language what the statement does.
The most popular implementation of Pascal programming language was the Turbo Pascal compiler by Borland in early 1980s. The key to success was a compact compiler which generated executable code and an integrated development environment (IDE) where you could write, run and debug your programs. Turbo Pascal significantly contributed to popularity of Pascal programming language. In 1990s Turbo Pascal evolved into Delphi--a visual IDE for Windows.
In embedded systems Pascal is rarely seen. One of the reasons is probably the lack of Pascal compilers for microcontrollers. There is absolutely no reason why Pascal could not be used in embedded world. Regardless of the programming language used, the output of compilers, either C or Pascal, can be a compact optimized code. On the other hand, there is a plethora of libraries written in C language for any imaginable task. This usually implies using a C compiler for embedded development.
One of the successful implementations of Pascal programming language in embedded world is Turbo51--Pascal compiler for 8051 microcontrollers. It is a command line compiler with Turbo Pascal syntax. If you are familiar with Turbo Pascal then you will be able to quickly start programming for any 8051-compatible microcontroller. Turbo51 supports all memory models in 8051 and generates a compact and optimized code that can run even in memory-limited versions of 8051 microcontrollers.
It is up to you to decide which language you will use. Of course, in many cases this decision is already made because of portability or team development issues. But if you don't check other options you will never know about advantages they offer.
Thursday, 19 August 2010
JTAG - Standard Test Access Port and Boundary - Scan Architecture
When you have an integrated circuit (IC) or many such devices on a board, where each IC has 100 or more pins, it is mandatory to have some tool to test connections and verify operation. Having this in mind, an expert group prepared a specification for testing that was standardized in 1990 as the IEEE Std. 1149.1. It is also known as the JTAG (Joint Test Action Group) standard.
JTAG is a method for testing connections on printed circuit boards (PCBs) that are implemented at the integrated circuit (IC) level. It is very difficult to test complex circuits with traditional in-circuit testers. Because of physical space constraints and inability to access very small components and BGA devices, the cost for board testing has increased significantly. JTAG is an elegant solution to overcome problems with physical in-circuit testers.
With JTAG you can test interconnects between integrated circuits on a board without using physical test probes. This is a big advantage because you don't need any additional customized tool for testing. Of course, the device has to be JTAG enabled. This means an additional cell (a boundary-scan cell) for each pin. Boundary-scan cell can set or read data on each pin. Boundary-scan cells are connected together and the data is serially shifted into the boundary-scan cells. The process is controlled from a serial data path called the scan path or scan chain. This is the basic principle of the JTAG interface.
JTAG eliminates the need for a large number of test vectors, which would be needed to initialize all the devices. Using JTAG means shorter test times, increased diagnostic capability higher test coverage, and lower equipment cost. Although there are many variations of the JTAG header on the board it is possible to use standard JTAG signals with almost any JTAG interface and boundary-scan software.
An additional benefit with JTAG interface is that it can be also used for programming and debugging. Many microcontrollers, FLASH memories, FPGAs and similar devices can be programmed via JTAG interface. And the same interface can be used for debugging. JTAG is a big step toward standard interfaces in electronics industry.
There are many JTAG cables that can be used on more than one device. In fact, JTAG cable is more than a cable. Usually it has some small electronics to boost signals and to provide standard computer interface. The price of the simplest JTAG cable can be as low as $5.
If you are interested in details you can visit http://JtagCables.com and read more about the JTAG standard and various JTAG cables used by the industry.
Wednesday, 18 August 2010
I2C Analyzer - Monitor and Control I2C Bus
There is almost no embedded system that has no peripheral devices. Even if the system needs only I/O lines there are many cases where the microcontroller has not enough pins. Port expanders are very popular because you can place them anywhere and you don't have to make long connections from the microcontroller to remote board areas for each I/O signal. Most port expanders and other peripheral devices use I2C bus to connect to the microcontroller.
I2C bus is a simple serial communication bus and protocol. It needs only two control signals, SCL and SDA. Writing software to support I2C devices is easy. Many microcontrollers have built-in hardware support. But even if the I2C is not directly supported you can write few short routines to send and receive data. I2C devices are simple to control so they are widely used even for projects intended for absolute beginners.
If you are developing embedded systems either professionally or just for fun you will sooner or later come into position where some devices will not respond to I2C commands or they won't behave as expected. In such cases there are only two basic approaches. The first one is to add debug routines to monitor I2C communication in order to find the cause of the problem. This approach works very well if the problem is in the software but it is time consuming and you need some skills to investigate data at right places and it doesn't find hardware related problems. The second approach means using external device to monitor I2C communication.
This way you can easily check if the software is sending right commands and if the device is responding properly. One popular method for I2C analysis is a module or extension for some digital storage oscilloscopes. This module enables decoding of I2C messages and displaying a complete communication over I2C bus. This is very convenient but costly debugging method because the price of the DSO including I2C module is beyond reach for many hobby programmers.
Another very popular but still professional way of debugging I2C bus is by using a simple USB to I2C interface. This device listens to the I2C communication and the software running on a PC decodes packets and displays all the data related to the I2C communication. It is also possible to save captured data for later analysis or to set triggers for specific events to capture only communication related to one I2C address.
Another great function of advanced I2C analyzers is the capability to act as I2C master. This way you can send I2C packets and receive responses from slave devices. This is the quickest way to discover what is not working as it should.
Such I2C analyzers are cheap and offer many advanced features also for decoding other popular protocols like SPI, JTAG and UART. They are very practical, can be connected to any PC including laptop and some advanced models offer also basic functions of oscilloscope or logic analyzer. Once you see what packets are sent and how individual devices respond to commands from the software it is very easy to find the cause of the problem. In some cases it will be wrong I2C address that is being used or wrong packet format but it may also happen that the problem is in the faulty device or device connections.