Beruflich Dokumente
Kultur Dokumente
Chip type
: ATmega8535L
Program type
: Application
AVR Core Clock frequency: 11.059200 MHz
Memory model
: Small
External RAM size
:0
Data Stack size
: 128
*****************************************************/
#include <mega8535.h>
#include <stdio.h>
#include <delay.h>
unsigned char data;
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
//LCD Initiation
#define LCD_RS_HI PORTC|=(1<<7)
#define LCD_RS_LO PORTC&=~(1<<7)
#define LCD_EN_HI PORTC|=(1<<6)
#define LCD_EN_LO PORTC&=~(1<<6)
#define LCD_D4_HI PORTC|=(1<<5)
#define LCD_D4_LO PORTC&=~(1<<5)
#define LCD_D5_HI PORTC|=(1<<4)
#define LCD_D5_LO PORTC&=~(1<<4)
#define LCD_D6_HI PORTC|=(1<<3)
#define LCD_D6_LO PORTC&=~(1<<3)
#define LCD_D7_HI PORTC|=(1<<2)
#define LCD_D7_LO PORTC&=~(1<<2)
//==============================================
#define line1 0x00
#define line2 0x40
#define _ALTERNATE_PUTCHAR_
void LCD_STROBE()
{
LCD_EN_HI;
LCD_EN_LO;
}
void lcd_write(unsigned char datalcd)
{
if(datalcd & 0x80) {LCD_D7_HI;} else {LCD_D7_LO;}
if(datalcd & 0x40) {LCD_D6_HI;} else {LCD_D6_LO;}
if(datalcd & 0x20) {LCD_D5_HI;} else {LCD_D5_LO;}
void main(void)
{
// local variables PORT
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0xFF;
//PORTC=0x00;
//DDRC=0x00;
DDRC=255;
init_lcd();
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1386.900 kHz
// Mode: Ph. correct PWM top=0x00FF
// OC1A output: Non-Inv.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0xA1;
TCCR1B=0x0C;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous