120 likes | 284 Views
University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering. Microcontroller Lab. 1:. General I/O Ports. In this session, we will . Review the previous session. Determine on how to program general I/O Ports. Determine on the software package. Review.
E N D
University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering Microcontroller Lab. 1: General I/O Ports
In this session, we will • Review the previous session. • Determine on how to program general I/O Ports. • Determine on the software package.
Review • Micro WHAT ?? Processor, computer or controller?? • Microcontroller’s basic architectures, and basic modules? • what are the differences between using Assembly language and C-language ?
Atmega 32 pin description Dual nature of most of the 40 pins. Serial communications Analog to Digital Conversion Voltage supply < Ground. << 4 I/O ports; PORTA ( ADC ) PORTB,PORTC PORTD. interrupt pins 40 pins structure, with 32 I/O pins. The pins mostly have a dual functionalty nature, i.e. it does more than one job. we will concentrate on atmega 32 many reasons ( availabilty, ease of use, suitable for simple apps and with a powerful RISC architecture and good processing power and RAM/ROM capacity. in this sesion we discuss some of the pins, furthur details will be presented later in this lap.
General Digital I/O Ports • The Atmel Atmega32 is equipped with 4 8-bits general purpose I/O ports designed PORTA, PORTB, PORTC, and PORTD. • Each port pin can be used as input or output. • When initialization we adjust the ports as IN or OUT ports, a sample of an initialization code is given below DDRB = 0x00; //make port b as input PORTB = 0x00; //disable pull-ups and make it tri stat.
All these ports have two functions: general digital I/O ports and alternate functions for the peripheral features on the device. • enabling the alternate function of some of the port pins does not affect the use of the other pins in the port as general digital I/O
Each port has three registers associated with it: • Data Direction Register (DDRx): used to set a specific port pin to either output (1) or input (0). • Data Register (PORTx): used to write output data to the port. • Port Input Pins (PINx): used to read input data from the port.
Software packages • In order to program the AVR MCU we use a special C compiler packed with hardware oriented libraries to ease the dealing with MCU hardware; AVR Codevision. • The codevision has a special feature that helps the programmer to generate the initialization code without having to write it from scratch; you only needs to know the features of the MCU that you are using for the certain app at hand and how you are going to use them.
Software packages; For simulation purposes we have the proteues application for electronics circuits simulation. And in order to have the program downloaded in the MCU we use the .hex file version generated by the code vision; this file is downloaded to the MCU using a communication interface; Ponyprog. Ponyprog is a serial device programmer software with a user friendly GUI framework available for Windows95/98/ME/NT/2000/XP and Intel Linux. Its purpose is reading and writing every serial device. At the moment it supports I²C Bus, Microwire, SPI EEPROM, the Atmel AVR and Microchip PIC micro.