Skip to main content

Posts

Showing posts with the label AVR programming

AVR data format and directives

In this section we look at some widely used data formats and directives supported by the AVR assembler. AVR data type The AVR microcontroller has only one data type. It is 8 bits, and the size of each register is also 8 bits. It is the job of the programmer to break down data larger than 8 bits (00 to OxFF, or 0 to 255 in decimal) to be processed by the CPU. The data types used by the AVR can be positive or negative. The bit-addressable data is discussed in later. Data format representation There are four ways to represent a byte of data in the AVR assembler. The numbers can be in hex, binary', decimal, or ASCII formats. The following are examples of how each works. Hex numbers There are two ways to show hex numbers: 1. Put Ox (or OX) in front of the number like this: LDI RI 6, ox99 2. Put S in front of the number, like this: R22, $99. We use both Of these methods in this book, because many application notes out there use one of them and we need to get used to them. ...

AVR Instruction Set

Not completed, will be completed ASAP. Please visit this post using a browser that has better html5 text support. ADC Rd, Rr ;Add with Carry two Registers 0≤d≤31, 0≤r≤31 ;Rd← Rd + Rr+C Type: Arithmetic instruction Adds two registers and the contents of the C flag and places the result in the diestination register Rd. Flags: H, S, V, N, Z, C     Cycles: 1 Example:       ;Add R1:RO to R3:R2 add r2,r0       ;Add low byte adc r3,r1       ;Add with carry high byte ADD Rd, Rr ;Add two Registers 0≤d≤31, 0≤r≤31 ;Rd← Rd + Rr Type: Arithmetic instruction Adds two registers without the C flag and places the result in the destination register Rd. Flags: H, S, V, N, Z, C     Cycles:1 Example: add r1, r2       ;Add r2 to r1 (r1=r1+r2) add r28,r28   ;Add r28 to itself (r28=r28+r2...

AVR Assembly language Programming

Introduction to AVR assembly language programming In this section we discuss Assembly language format and define some widely used terminology associated with Assembly language programming. While the CPU can work only in binary, it can do so at a very high speed. It is quite tedious and slow for humans, however, to deal with Os and Is in order to program the computer. A program that consists of Os and Is is called machine language. In the early days of the computer, programmers coded programs in machine language. Although the hexadecimal system was used as a more efficient way to represent binary numbers, the process of working in machine code was still cumbersome for humans. Eventually, Assembly languages were developed, which provided mnemonics for the machine code instructions, plus other features that made programming faster and less prone to error. The term mnemonic is frequently used in computer science and engineering literature to refer to codes and abbreviations that are rel...