Thursday, October 24, 2013

ATmega32 LED blinking Experiment

The first and simplest project for any microcontroller is LED Blinking.

Circuit Diagram


Components Required

  • ATmega32 microcontroller
  • Programmer Board
  • LEDs
  • Crystal - less than 16 MHz.
  • Capacitors - 2 
  • +5 V supply
  • Breadboard
  • Connecting Wires
Optional
  • Resistors - 330 Ohms to be connected in series with the LEDs(not shown in the circuit diagram) 

Description

  • Here, all pins of PORT B are declared as output ports as all the LEDs are connected to the pins of PORTB.
  • A crystal is connected to the XTAL1 and XTAL2 pins to provide the clock pulse.
  • Reset is connected to +5V.
Source Code

#include <avr/io.h> 
#include <util/delay.h> 

#define F_CPU 1000000UL    // Defines the frequency of external crystal
    
int main()
 { 
          /* The Data direction register of all Pins of Port B is Set as Output*/
         DDRB = 0xFF;                
PORTB = 0x00;               // Initially all pins of Port B are set as Output Low
   while (1)                               // Infinite Loop
   {
  PORTB = 0b11111110;   // all LEDs will glow except the first LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b11111101;   // all LEDs will glow except the second LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b11111011;   // all LEDs will glow except the third LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b11110111;   // all LEDs will glow except the fourth LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b11101111;   // all LEDs will glow except the fifth LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b11011111;   // all LEDs will glow except the sixth LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b10111111;   // all LEDs will glow except the seventh LED 
  _delay_ms(500);            // delay of 500 milliseconds 
  PORTB = 0b01111111;   // all LEDs will glow except the eight LED 
  _delay_ms(500);            // delay of 500 milliseconds 
   }
   return 0;
 }



Thankyou for Reading

Status Register of ATmega32

The Status Register contains information about the result of the most recently executed arithmetic
instruction. This information can be used for altering program flow in order to perform
conditional operations. Note that the Status Register is updated after all ALU operations, as
specified in the Instruction Set Reference. This will in many cases remove the need for using the
dedicated compare instructions, resulting in faster and more compact code.
The Status Register is not automatically stored when entering an interrupt routine and restored
when returning from an interrupt. This must be handled by software.

The AVR Status Register – SREG – is defined as:



• Bit 7 – I: Global Interrupt Enable
The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual interrupt
enable control is then performed in separate control registers. If the Global Interrupt Enable
Register is cleared, none of the interrupts are enabled independent of the individual interrupt
enable settings. The I-bit is cleared by hardware after an interrupt has occurred, and is set by
the RETI instruction to enable subsequent interrupts. The I-bit can also be set and cleared by
the application with the SEI and CLI instructions, as described in the instruction set reference.

• Bit 6 – T: Bit Copy Storage
The Bit Copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T-bit as source or destination
for the operated bit. A bit from a register in the Register File can be copied into T by the
BST instruction, and a bit in T can be copied into a bit in a register in the Register File by the
BLD instruction.

• Bit 5 – H: Half Carry Flag
The Half Carry Flag H indicates a half carry in some arithmetic operations. Half Carry is useful in
BCD arithmetic.

• Bit 4 – S: Sign Bit, S = N ⊕ V
The S-bit is always an exclusive or between the Negative Flag N and the Two’s Complement
Overflow Flag V.

• Bit 3 – V: Two’s Complement Overflow Flag
The Two’s Complement Overflow Flag V supports two’s complement arithmetics.

• Bit 2 – N: Negative Flag
The Negative Flag N indicates a negative result in an arithmetic or logic operation.

• Bit 1 – Z: Zero Flag
The Zero Flag Z indicates a zero result in an arithmetic or logic operation.

• Bit 0 – C: Carry Flag
The Carry Flag C indicates a carry in an arithmetic or logic operation. 

Pin Descriptions of ATMEGA32


Pin Diagram

Description

VCC Digital supply voltage.

GND Ground.

Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter or 8-bit bi-directional I/O port(if the A/D Converter is not used). Port pins can provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port B (PB7..PB0)         Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B also serves the functions of various special features.

Port C (PC7..PC0)  Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset occurs. The TD0 pin is tri-stated unless TAP states that shift out data are entered. Port C also serves the functions of the JTAG interface and other special features of the ATmega32.

Port D (PD7..PD0)  Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D also serves the functions of various special features of the ATmega32.

RESET     Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. Pulses shorter than the minimum pulse length are not guaranteed to generate a reset.

XTAL1    Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.

XTAL2    Output from the inverting Oscillator amplifier.

AVCC    AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.

AREF    AREF is the analog reference pin for the A/D Converter.

Thankyou for Reading

Wednesday, October 23, 2013

Atmega32 Features


AVR  is a modified Harvard architecture 8-bit RISC single chip microcontroller which was developed by Atmel.

The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

Here are the features of Atmega32 one of the chips of AVR family.

Features
• High-performance, Low-power Atmel®AVR® 8-bit Microcontroller
• Advanced RISC Architecture
– 131 Powerful Instructions – Most Single-clock Cycle Execution
– 32 × 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16MHz
– On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory segments
– 32Kbytes of In-System Self-programmable Flash program memory
– 1024Bytes EEPROM
– 2Kbytes Internal SRAM
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C(1)
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– Programming Lock for Software Security
• JTAG (IEEE std. 1149.1 Compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels in TQFP Package Only
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby
• I/O and Packages
– 32 Programmable I/O Lines
– 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
• Operating Voltages
– 2.7V - 5.5V for ATmega32L
– 4.5V - 5.5V for ATmega32
• Speed Grades
– 0 - 8MHz for ATmega32L
– 0 - 16MHz for ATmega32
• Power Consumption at 1MHz, 3V, 25°C
– Active: 1.1mA
– Idle Mode: 0.35mA
– Power-down Mode: < 1μA


      Pin Configuration





Error Codes on The Internet

While surfing the net we come across a few error codes.
Lets see what do they mean.

Error Codes on The internet 
--------------------------------

100 Continue 
101 Switching Protocols 
200 OK Action completed successfully
201 Created Success following a POST command
202 Accepted The request has been accepted for processing, but the processing has not been completed.
203 Partial Information Response to a GET command, indicates that the returned meta information is from a private overlaid web.
204 No Content Server has received the request but there is no information to send back.
205 Reset Content 
206 Partial Content The requested file was partially sent. Usually caused by stopping or refreshing a web page.
300 Multiple Choices 
301 Moved Permanently Requested a directory instead of a specific file. The web server added the filenameindex.html, index.htm, home.html, or home.htm to the URL.
302 Moved Temporarily 
303 See Other 
304 Not Modified The cached version of the requested file is the same as the file to be sent.
305 Use Proxy 
400 Bad Request The request had bad syntax or was impossible to be satisified.
401 Unauthorized User failed to provide a valid user name / password required for access to file / directory.
402 Payment Required 
403 Forbidden The request does not specify the file name. Or the directory or the file does not have the permission that allows the pages to be viewed from the web.
404 Not Found The requested file was not found.
405 Method Not Allowed 
406 Not Acceptable 
407 Proxy Authentication Required 
408 Request Time-Out 
409 Conflict 
410 Gone 
411 Length Required 
412 Precondition Failed 
413 Request Entity Too Large 
414 Request-URL Too Large 
415 Unsupported Media Type 
500 Server Error In most cases, this error is a result of a problem with the code or program you are calling rather than with the web server itself.
501 Not Implemented The server does not support the facility required.
502 Bad Gateway 
503 Out of Resources The server cannot process the request due to a system overload. This should be a temporary condition.
504 Gateway Time-Out The service did not respond within the time frame that the gateway was willing to wait.
505 HTTP Version not supported

Top Five Most Dangerous Computer Viruses in History

Information about top five computer viruses till date.

Conficker (2008)

The most recent and worldwide spread internet virus also holds the title for the most dangerous computer worm. It attacks the family of Microsoft Windows operating systems ranging from Windows 2000 to Windows 7 and Windows Server 2008 R2. The virus has struck more than 12 million computers worldwide by now. Its operating principle is based on finding vulnerable Windows sides associated with buffer overflows, and by using fake RPC-query executes a code, turning off the service and updating Windows departments, and blocking access to the sites of a large number of anti-virus manufacturers.

My Doom (2004)

The fastest e-mail virus ever. It did spread exponentially through an algorithm instructing any following computer to send even more spam than the previous one. In addition, it modified the operating system by blocking access to the websites of anti-virus companies, news feeds, and various sections of the Microsoft website. On its account there even is a DDOS-attack on the Microsoft site. Its author(s) still remain unknown but the Linux OS adepts are suspected for doing this in attempt to undermine the authority and to show the vulnerability of the Windows operating system.

Nimda (2001)

The name originates from the word «admin», just reversed. Once the virus got on the computer, it instantly “subscribed” itself as an administrator. Subsequently it cheated and broke the design of numerous websites, blocked access to hosts, IP-addresses, etc. Moreover, it intruded computers in such an expertly and efficiently manner that 22 minutes after its creation, it became the widest-spread computer virus on the globe

ILOVEYOU (2000)

One of the trickiest computer malware ever. Email users received a message entitled “I Love You” with an attached file to it. Due to this sweet message, people downloaded the file and what they got was a script that started sending email messages in incredible numbers and deleted important PC files. The results are still shocking nowadays: 10 percent of all existing computers on the globe at that moment were infected with it, thus, causing damages that amounted to $ 5,5 billion

Melissa (1999)

An internationally well-known email worm that infected MS Word document files and sent copies of them via e-mail messages using MS Outlook. The virus spread at a breakneck speed, and therefore the damage caused by it was estimated at more than $ 100 million.

Increase Virtual RAM to Increase Your Pc Speed

The empty memory of the C drive of the PC can be used as virtual RAM to increase the speed of PC to some extent.

The speed of the computer depends on the size of the RAM which you have got in your PC. If your RAM size is small and you are running more applications at a time, then you may face different problems.To avoid such problems windows create a virtual memory space on your hard disk and it automatically manages it. Virtual memory is the reserved memory space in your hard disk drive to assist RAM. By increasing the virtual memory available for your system you can increase the performance of your system. Please follow the simple steps below to increase your system's performance.
  • Right Click on your Computer and choose Properties.
  • Click on Advanced system settings.
  • Go to the Advanced tab and click on Settings.

  • Now click on Change... in the Advanced tab of Performance 
Options pop up. 
  • Uncheck the Automatically manage paging file size for all drives and set Initial size as about 2048 to 4096 and Maximum size less than the empty space in the C drive.
  • Now restart the system and feel the difference.

                   Than you for reading...