hELLo,
I wrote a simple program to display encoder count on my LCD, but it did'nt work, any body can help me ?, here is the code
#include <mega2560.h>
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <lcd.h>
#define MAX 0xFF
int count1;
unsigned char lcd1[5];
void LCD_Setting()
{
/*
LCD Configuration
*/
#asm
.equ __lcd_port=0x08 ;PORTC
#endasm
}
void Oscillator_Setting()
{
/*
Crystal Division Factor : 1
*/
#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
}
void Ports_Setting()
{
PORTD= 0b00000000;
DDRD = 0b00000000;
}
void Interrupt_Setting()
{
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Rising Edge
// INT1: Off
// INT2: Off
// INT3: Off
// INT4: Off
// INT5: Off
// INT6: Off
// INT7: Off
EICRA=0x03;
EICRB=0x00;
EIMSK=0x01;
EIFR=0x01;
}
// External Interrupt 0 service routine
interrupt [INT0] void ext_int0_isr(void)
{
delay_ms(60);
count1++;
}
void main(void)
{
Oscillator_Setting();
Ports_Setting();
LCD_Setting();
Interrupt_Setting();
lcd_init(16);
#asm("sei")
while(1)
{
lcd_gotoxy(0,0);
lcd_putsf("PLS = ");
lcd_puts(lcd1);
itoa (count1,lcd1);;
}
}