سلام دوستان
من یه برنامه keypad نوشتم و وقتی کامپایل مکنم خطا نمی ده ولی کد هگز هم برای شبیه سازی تولید نمی کنه. فقطم با این برنامه این مشکل رو دارم. دوستان ممنون میشم کمک کنید.
[PHP]
#include <mega16.h>
#include <delay.h>
#asm
equ__lcd_port=0x1B
#endasm
#include <lcd.h>
#define c1 PINB.4
#define c2 PINB.5
#define c3 PINB.6
#define c4 PINB.7
// Declare your global variables here
flash char row[]={0xfe,0xfd,0xfb,0xf7};
flash char data_key[]={
'1','2','3','A',
'4','5','6','B',
'7','8','9','C',
'*','0','#','D'};
unsigned char ac,table;
unsigned int r;
void keypad(){
lcd_gotoxy(0,1);
lcd_putsf("~");
while (1){
for (r=0;r<4;r++){
ac=4;
PORTB=row[r];
DDRB=0x0f;
if (c1==0) ac=0;
if (c2==0) ac=1;
if (c3==0) ac=2;
if (c4==0) ac=3;
if (!(ac==4)){
table=data_key[(r*4)+ac];
lcd_putchar(table);
while (c1==0) {}
while (c2==0) {}
while (c3==0) {}
while (c4==0) {}
delay_ms(50);
}
}
}
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTA=0x00;
DDRA=0xFF;
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0xFF;
DDRB=0x0F;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("test keypad");
keypad();
}
[/PHP]