سلام به همگی
بی مقدمه میرم سر اصل مطلب.... در یک پروژه (( اسیلوسکوپ با Avr و glcd )) میخوام هشت تا پوش باتن رو بطور دلخواه بخونم و با اجرای اونها توابعی رو Run کنم ولی نمیشه...
شماتیک کلی برنامه اینجوری هست...
خود برنامه هم اینه در کدویژن 2.05.3 نوشته شده ودر آن از توابعی که برای کار با glcd بکار میرن هم استفاده شده...
کد:
#include <delay.h>
#include <mega32.h>
// Graphic LCD functions
#include <glcd.h>
// Font used for displaying text
// on the graphic LCD
#include <font5x7.h>
GLCDINIT_t glcd_init_data;
int i,j,p,a2d;
int k=0;
int data[128];
// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
if (k<128)
{
k++;
data[k]=ADCW;
glcd_setpixel (k,data[k]);
ADCSRA|=1<<ADSC;
}
}
void selectch(void);
void main(void)
{
PORTB=0x00;
DDRB=0x00;
// Graphic LCD initialization
// The KS0108 connections are specified in the
// Project|Configure|C Compiler|Libraries|Graphic LCD menu:
// DB0 - PORTC Bit 0
// DB1 - PORTC Bit 1
// DB2 - PORTC Bit 2
// DB3 - PORTC Bit 3
// DB4 - PORTC Bit 4
// DB5 - PORTC Bit 5
// DB6 - PORTC Bit 6
// DB7 - PORTC Bit 7
// E - PORTD Bit 0
// RD /WR - PORTB Bit 1
// RS - PORTB Bit 2
// /RST - PORTB Bit 3
// CS1 - PORTD Bit 4
// CS2 - PORTD Bit 5
// Specify the current font for displaying text
glcd_init_data.font=font5x7;
// No function is used for reading
// image data from external memory
glcd_init_data.readxmem=NULL;
// No function is used for writing
// image data to external memory
glcd_init_data.writexmem=NULL;
glcd_init(&glcd_init_data);
while (1)
{
glcd_outtextxyf(0,0,"DIGITAL OSILLOSCOPE");
glcd_outtextxyf (0,22,"BY AVR MICOCTRL");
glcd_outtextxyf (0,45,"HAMID REZA RABET" );
delay_ms(80);
glcd_clear();
for (i=0;i<128;i+=2){
glcd_setpixel (64,i);
}
for (j=0;j<128;j+=2){
glcd_setpixel (j,32);
}
glcd_putcharxy( 1, 56, 'v');
glcd_putcharxy( 66, 56, 't');
glcd_putcharxy( 6, 56, '=');
glcd_putcharxy( 71, 56, '=');
selectch();
ADCSRA = 0b11100111;
ADMUX = 0b01100000;
SFIOR = 0x00;
a2d = ADCW;
p = (1024 - (a2d))/16;
for( i=0;i<1024;i++){
for(j=0;j<=a2d ; j++)
glcd_setpixel (p,i);
}
/////////////////// namayesh noghat bedast amadeh az tabdil bar roye 128 pixel ofoghi.
for (i=0;i<127;i++){
do{
i=0;
glcd_setpixel(i,p);
delay_us(100);
i++;
if(i==128)
i=0;
}
while(1);
}
}
}
///////////// defination of selechch.
void selectch (void)
{
//// first key for first channel
if(!PINB.0)
{
delay_ms(20);
if(!PINB.0)
{
glcd_outtextxyf (2,5,"SEL CH1");
ADMUX = 0b01100000;
delay_ms(300);
while(!PINB.0);
}
}
}
مشکل اینجاست که قرار بود با زدن پوش باتنی که روی پورت PORTB.0 هست عبارت SEL CH1 در Glcd نمایش داده بشه ولی الان اصلا میکرو از پوش باتن فرمان نمیگیره که بخواد کاری انجام بشه.... نمیدونم چرا... دارم دیونه میشم...!!
شما دوستان که مثل من تازه کار نیستید... خواهشا یه نگاهی به این برنامه و تابع selectch بندازید تا دریابید مشکل کار کجاست و بمن کمک کنید.
در ضمن لینک برنامه ای که نوشتم به همراه پروتئوسش اینه:
http://uplod.ir/sk8x9qob145k/osciloscope...am.rar.htm
بینهایت از محببتون سپاسگذارم.