ATmega169 programming



The ATmega169 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega169 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.               

The AVR core combines a rich instruction set with 32 general purpose working registers.
All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers.

 The ATmega169 provides the following features: 16K bytes of In-System Programmable Flash with Read-While-Write capabilities, 512 bytes EEPROM, 1K byte SRAM, 54 general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundary-scan, On-chip Debugging support and programming, a complete On-chip LCD controller with internal step-up voltage, three flexible Timer/Counters with compare modes, internal and external interrupts, a serial programmable USART, Universal Serial Interface with Start Condition Detector, an 8-channel, 10-bit ADC, a programmable Watchdog Timer with internal Oscillator, an SPI serial port, and five software selectable power saving modes. The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Powerdown mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next interrupt or hardware reset. In Power-save mode, the asynchronous timer and the LCD controller continues to run, allowing the user to maintain a timer base and operate the LCD display while the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except asynchronous timer, LCD controller and ADC, to minimize switching noise during ADC conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest of the device is sleeping. This allows very fast start-up combined with low-power consumption.                                                                                                                   


 • High Performance, Low Power AVR® 8-Bit Microcontroller

• Advanced RISC Architecture
– 130 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-Chip 2-cycle Multiplier

• Non-volatile Program and Data Memories
– 16K bytes of In-System Self-Programmable Flash
Endurance: 10,000 Write/Erase Cycles
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– 512 bytes EEPROM
Endurance: 100,000 Write/Erase Cycles
– 1K byte Internal SRAM
– 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
– 4 x 25 Segment LCD Driver
– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Universal Serial Interface with Start Condition Detector
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
• Speed Grade:
– ATmega169V: 0 - 4 MHz @ 1.8 - 5.5V, 0 - 8 MHz @ 2.7 - 5.5V
– ATmega169: 0 - 8 MHz @ 2.7 - 5.5V, 0 - 16 MHz @ 4.5 - 5.5V
• Temperature range:
– -40°C to 85°C Industrial
• Ultra-Low Power Consumption
– Active Mode:
1 MHz, 1.8V: 350μA
32 kHz, 1.8V: 20μA (including Oscillator)
32 kHz, 1.8V: 40μA (including Oscillator and LCD)
– Power-down Mode:
0.1μA at 1.8V

                                               1.ADC programming
 * GccApplication1.c
 * Created: 8/14/2012 8:40:05 PM
 *  Author: Brothers
 * Analog to Digital converter
#include <avr/io.h>
int main(void)
            SREG|=0x80;  //gloabal interrupt enable
            ADMUX|=0xC0;        //internal 1.1v reference voltage
            ADCSRA|=0x84;       //AD enable,AD interrupt enable
            ADCSRA|=0x20;       //positive edge trigger
        ADCSRB|=0x40;                                    //free running mode
                        ADCSRA|=0x40;                   //start conversion
                       while(ADCSRA&0x40);        //stay until conversion completed
                        PORTB=ADCH;                    //write higher byte onto the port-b
                        PORTC=ADCL;                     //write lower byte onto the port-c


                                                              2.  USART_Rxr
// serial data receive using UART
#include <avr/io.h>
unsigned int i,data;
void rx_data(void);
int main(void)
            UCSRA|=0x00;          //---u2x=0
            UCSRB|=0x69;           //----txcie=1,udrie=1,txen=1,txb8=1
            UBRR|=0x67; //--baud rate 9600 at fosc=16MHz, 103'D
            UCSRC|=0x26;           //--asyn,evenparity,1-stop bit,data size 8 bit,
                        rx_data();        //--calling rx_data
//---receive data function
void rx_data()
            DDRB=0xFF; //---output port

            while(TXC==0);         //stay until receive buffer full
            data=UDR;     //load udr data into data
            PORTB=data; //write data onto the port-b

 * atmega169.c
 *  Serial Data transmission using UART
 * Created: 8/14/2012 6:55:09 PM
 *  Author: Brothers

//-----USART data transmission
#include <avr/io.h>
unsigned char data[10]="EMBEDDED";
unsigned int i;
void tx_data(char x);
int main(void)
            UCSRA|=0X00;         //---u2x=0
            UCSRB|=0X69;          //---txcie=1,udrie=1,txen=1,txb8=1
            UCSRC|=0X26;          //---asyn,evenparity,1-stop bit,data size 8 bit,
            UBRR=0X67; //---baud rate 9600 at fosc=16MHz, 103'D
               tx_data(data[i]);       //---sending char to tx_data
//---transmitter function
void tx_data(char x)
            UDR=x;          //---------------loading USART data buffer with char
            while(!(UCSRA & 0X40));    //-----wait until transmission completed
            UCSRA=(0<<TXC);              //--make txc to 0 in UCSRA


More stuff Coming soon.... 


No comments:

Post a Comment

comment here