Sunday, 5 February 2012

Hex File Format


The Intel hex (ihex) generally known as hex file, is a format used to store machine language code in hexadecimal form. It is widely used format to store programs to be transferred to microcontrollers, ROM and EEPROM. The compilers convert the programs written in assembly, C etc into corresponding hex files, which are dumped into the controllers using burners/programmers. This article explores the details of the hex file format.
 
The microcontroller understands machine language consisting of zeroes and ones. It’s difficult rather practically impossible for humans to write codes in zeros and ones. Hence we use some high level languages like C, C++, Java, etc. And later a compiler is used to convert these codes into machine language which are stored in a hex file format. A hex file is a text file with the extension .hex.
 
Hex File Format
The above image shows a typical hex file when opened with notepad or any other text editor. Every line follows a specific structure explained below.
 
:CCAAAATTXXXXX......XXSS
 
Example:
 

:100000000C942A000C9434000C9434000C943400AA

           
1.      Every line in a hex file always starts from colon (:)
2.      The first two digits CC (Character Count) represent the total number of data byte in that line. Here in this example, 10 (hexadecimal) are the first two digits which mean that there is 16 byte (in decimal) of data in the line.
3.      The next four digits represent the starting address of the memory where the data stored in the line needs to be dumped. 4.      After address the next two digits represent whether this is the last line of code or not. TT=0, means the code is not complete and there are more lines after this line and TT=1 means this is the last line of the code.
5.      XXXX…..XX are the data bytes which have to be dumped into the memory. The number of data bytes in a particular line is equal to the number indicated by character count digits (CC).
6.      SS is the checksum byte of that line.

The hex file is a text file so one can easily change contents of a hex file. The corrupted line can be identified using the check sum) (SS) byte.
source:engineersgarage.com

All About Resistors part-11


Circuit Analysis: 
The AC and DC behavior of resistors are the same. In series combination, the equivalent resistance is the sum of the resistances and is given by:
R = R1 + R2 + R3 +……
The current through the branch remains constant while voltage drops across different resistors are different and are given by the product of current and the individual resistances.                  
In shunt combination, the equivalent resistance is given by:
1/R = 1/R1 + 1/R2 +1/R3+…..
The voltage across branches remains constant while currents in different branches are different and are given by supply voltage divided by the individual resistances.
Through analysis, we can conclude that in case of two branch circuits, current in one branch is the product of supply current and the resistance in other branch divided by the sum of resistances. This is called ‘Shunt formulae’
IR1 = I*R2/ (R1+R2)
IR2 = I*R1/ (R1+R2)
There can also be star (Y and T) and delta (delta and pie) combination of resistances.
A delta network can be converted into star network by using the formulae:
RA = RAB*RAC/ (RAB+RAC+RBC)
R= RAB*RBC/ (RAB+RAC+RBC)
RC = RAC*RBC/ (RAB+RAC+RBC)
Mnemonics - For delta to star conversion, the resistor at a node is the product of resistances in the adjacent branches connected to that node divided by the sum of all three delta resistances.
A star network can be converted into delta network by using the formulae:
RAB = RA +RB +RA*RB/RC 

RAC = RA +RC +RA*RC/RB

RBC = RC +RB +RC*RB/RA

Mnemonics - For star to delta conversion the resistance at a branch is the sum of the resistances held by the two nodes of the branch with the product of those resistances divided by the opposite resistance.