Mesaj Önizleme  Konuyu Gönder 
16f877+74hc595 8 satır kayan yazı ccs c kodlu
Yazar Mesaj
mhtekinci
Member
***


Mesajlar: 1
Grup: Registered
Katılım: May 2010
Statü: Çevrimdışı
Karma Puanı: 0
Mesaj: #1
16f877+74hc595 8 satır kayan yazı ccs c kodlu

#include <16F877.H>
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A4, rcv=PIN_A5,RESTART_WDT, ERRORS)

#define PIN_ST_CP PIN_C2 // RCLK ----> Pin 12 ST_CP
#define PIN_SH_CP PIN_C3 // SRCLK ---> Pin 11 SH_CP
#define PIN_SER_IN PIN_C5 // SER -----> Pin 14
//#define PIN_MRS PIN_C1 // PIN 10
//#define PIN_OE PIN_C3 // PIN 13


#use fast_io(B)
#use fast_io©
#use fast_io(D)

long s1_char_size=41;
char s1[79];
long i;

//***********************sutunlara bağlı hc595**********************************
#define clock PIN_B0 // RCLK ----> Pin 12 ST_CP
#define latch PIN_B2 // SRCLK ---> Pin 11 SH_CP
#define data PIN_B1 // SER -----> Pin 14

void HC595_OUT_satir(unsigned char send_data)
{
unsigned char bit_mask;

for (bit_mask=1; bit_mask ;bit_mask <<=1)
{
// On an AVR you can set the bit directly and i'd use
//data = (send_data & bit_mask);

//Else use this if/else ....
if((send_data & bit_mask))
output_high(data);
else
output_low(data);

output_high(clock);
delay_us(1);
output_low(clock);
}

output_high(latch);
delay_us(1);
output_low(latch);
}
//******************************************************************************
void get_line1(void)
{
for(i=0; i<s1_char_size; i++)
{
if(kbhit())
{
s1[i]=getc();
delay_cycles(2);
printf("%C",s1[i]);
delay_us(1);
}
else
i -= 1;
}
}

const char msg_default[] = "MEFTAAAAA";

const char ascii1[32][5] = {
{0b00000000, // 0
0b00000000,
0b00000000,
0b00000000,
0b00000000}

{0b00000000, // 1
0b00000000,
0b01011111,
0b00000000,
0b00000000}

{0b00000000, // 2
0b00000111,
0b00000000,
0b00000111,
0b00000000}

{0b00010100, // 3 ("#" işareti)
0b01111111,
0b00010100,
0b01111111,
0b00010100}

{0b00100100, // 4 ("$" işareti)
0b00101010,
0b01111111,
0b00101010,
0b00010010}

{0b00100111, // 5 ("%" işareti)
0b00010101,
0b01101011,
0b01010100,
0b01110010}

{0b00110110, // 6
0b01001001,
0b01010110,
0b00100000,
0b01010000}

{0b00000000, // 7
0b00001011,
0b00000111,
0b00000000,
0b00000000}

{0b00000000, // 8 ( ")" işareti)
0b00011100,
0b00100010,
0b01000001,
0b00000000}

{0b00000000, // 9 ( "(" işareti)
0b01000001,
0b00100010,
0b00011100,
0b00000000}

{0b00101010, // 10
0b00011100,
0b01111111,
0b00011100,
0b00101010}

{0b00001000, // 11 ( "+" işareti)
0b00001000,
0b00111110,
0b00001000,
0b00001000}

{0b00000000, // 12 ( "'" işareti)
0b01011000,
0b00111000,
0b00000000,
0b00000000}

{0b00001000, // 13 ("-" işareti)
0b00001000,
0b00001000,
0b00001000,
0b00001000}

{0b00000000, // 14
0b01100000,
0b01100000,
0b00000000,
0b00000000}

{0b00100000, // 15 ("/" işareti)
0b00010000,
0b00001000,
0b00000100,
0b00000010}

{0b00111110, // 16 ( 0 rakamı )
0b01010001,
0b01001001,
0b01000101,
0b00111110}

{0b00000000, // 17 ( 1 rakamı)
0b01000010,
0b01111111,
0b01000000,
0b00000000}

{0b01110010, // 18 ( 2 rakamı)
0b01001001,
0b01001001,
0b01001001,
0b01000110}

{0b00100010, // 19 ( 3 rakamı)
0b01000001,
0b01001001,
0b01001001,
0b00110110}

{0b00011000, // 20 ( 4 rakamı)
0b00010100,
0b00010010,
0b01111111,
0b00010000}

{0b00100111, // 21 ( 5 rakamı)
0b01000101,
0b01000101,
0b01000101,
0b00111001}

{0b00111100, // 22 ( 6 rakamı)
0b01001010,
0b01001001,
0b01001001,
0b00110000}
{1, 113, 9, 5, 3} // 23
{54, 73, 73, 73, 54} // 24
{6, 73, 73, 41, 30} // 25
{0, 54,54,0,0} // {0, 54, 54,0,0,0}
// 26
{0, 91, 59, 0,0} // {0, 91, 59,0,0,0} // 27
{8, 20, 34, 65,0} // 28
{20, 20, 20, 20, 20} // 29
{65, 34, 20, 8,0} // 30
{2, 1, 81, 9, 6} // 31
};

const char ascii2[32][5] = {
{50, 73, 121, 65, 62} // 0
{124, 18, 17, 18, 124} // 1 A
{65, 127, 73, 73, 54} // 2 B
{62, 65, 65, 65, 34} // 3 C
{65, 127, 65, 65, 62} // 4 D
{127, 73, 73, 65, 65 } // 5 E
{127, 9, 9, 1, 1} // 6
{62, 65, 73, 73, 58} // 7
{127, 8, 8, 8, 127} // 8
{0, 65, 127, 65, 0} // {0, 65, 127, 65,0,0}
// 9
{32, 64, 65, 63, 1} // 10
{127, 8, 20, 34, 65} // 11
{127, 64, 64, 64, 64} // 12
{127, 2, 12, 2, 127} // 13
{127, 2, 4, 8, 127} // 14
{62, 65, 65, 65, 62} // 15
{127, 9, 9, 9, 6} // 16
{62, 65, 81, 33, 94} // 17
{127, 9, 25, 41, 70} // 18
{38, 73, 73, 73, 50} // 19
{1,1,127, 1, 1} // 20
{63, 64, 64, 64, 63} // 21
{7, 24, 96, 24, 7} // 22
{127, 32, 24, 32, 127} // 23
{99, 20, 8, 20, 99} // 24
{3, 4, 120, 4, 3} // 25
{97, 81, 73, 69, 67} // 26
{0, 127, 65, 65,0} // {0, 127, 65, 65,0,0}
// 27
{2, 4, 8, 16, 32} // 28
{0, 65, 65, 127,0} // {0, 65, 65, 127,0,0}
// 29
{4, 2, 1, 2, 4} // 30
{64, 64, 64, 64, 64} // 31
};

const char ascii3[32][5] = { // 0 -- 30 == 31 elements
{0, 0, 7, 11,0} // {0, 7, 11,0,0,0}
// 0
{32, 84, 84, 84, 56} // 1
{127, 40, 68, 68, 56} // 2
{56, 68, 68, 68,0} // 3
{56, 68, 68, 40, 127} // 4
{56, 84, 84, 84, 24} // 5
{8, 126, 9, 9, 2} // 6
{8, 84, 84, 84, 60} // 7
{127, 8, 4, 4, 120} // 8
{0, 68, 125, 64,0} // {0, 68, 125, 64,0,0}
// 9
{32, 64, 68, 61,0} // 10
{127, 16, 40, 68,0} // 11
{0, 65, 127, 64, 0} // {0, 65, 127, 64,0,0}
// 12
{124, 4, 120, 4, 120} // 13
{124, 8, 4, 4, 120} // 14
{56, 68, 68, 68, 56} // 15
{124, 20, 20, 20, 8} // 16
{8, 20, 20, 20, 124} // 17
{124, 8, 4, 4, 8} // 18
{72, 84, 84, 84, 36} // 19
{4, 63, 68, 68,0} // 20
{60, 64, 64, 32, 124} // 21
{28, 32, 64, 32, 28} // 22
{60, 64, 48, 64, 60} // 23
{68, 40, 16, 40, 68} // 24
{12,80, 80, 80, 60} // 25
{68, 100, 84, 76, 68} // 26
{0, 8, 54, 65,0} // {0, 8, 54, 65,0,0}
// 27
{0,0,119,0,0} // {0, 119,0,0,0,0} // 28
{0, 65, 54, 8,0} // {0, 65, 54, 8,0,0}
// 29
{2,1,2,4,2} // 30

{0b01111101, // ö harfi
0b10000010,
0b10000010,
0b10000010,
0b01111101,
}
};


void main(void)
{
int char_index;
int col_index;
int x = 0;
long MSD, LSD;
int delaycount;
int16 startposition;

set_tris_b(0);
set_tris_c(0x40);
set_tris_d(0);
HC595_OUT_satir(0);
output_c(0);
startposition = 0;

for(i=0; i<79; i++)
s1[i] = 46;

for(i=0; i<sizeof(msg_default); i++)
s1[i] = msg_default[i];

delay_ms(100);
do
{
if(!input(PIN_E1)) //BUTONA BASILDI MI?
{
do
{
delay_cycles(2);
printf("\f\r\n");
printf("\f\r\n Kac karakter.(0--99):");
MSD=getc();
delay_cycles(2);
printf("%C",MSD);
delay_us(1);
}while(!isamoung(MSD,"0123456789"));
do
{
LSD=getc();
delay_cycles(2);
printf("%C",LSD);
delay_us(1);
}while(!isamoung(LSD,"0123456789"));

s1_char_size = 10*(MSD-48) + (LSD-48);
delay_cycles(2);
printf("\r\n\n %lu karakter girin: ",s1_char_size);
get_line1();
}
delaycount=2; //-------> tarama hızı burdan ayarlanıyo..
while (delaycount)
{
col_index = startposition % 6;
char_index = startposition / 6;
if (char_index >= sizeof(s1))
{
startposition = 0;
char_index = 0;
col_index = 0;
}
x = s1[char_index];

// 74HC595 ler suruluyor
output_high(PIN_SH_CP);
output_high(PIN_ST_CP);
output_high(PIN_SER_IN);
output_low(PIN_SH_CP);
delay_us(1);
output_high(PIN_SH_CP);
output_low(PIN_SER_IN);

for (i=0;i<80;i++) // 80 tane kolon kullanıyoruz
{
// port_b=0;
output_low(PIN_ST_CP);
delay_us(200);
output_high(PIN_ST_CP);
delay_us(1);
output_low(PIN_SH_CP);
delay_us(1);
output_high(PIN_SH_CP);

if (col_index == 5)
{
col_index = 0;
char_index++;
if (char_index >= sizeof(s1))
char_index = 0;
x = s1[char_index];
}
else
{
if ( x < 32)
HC595_OUT_satir(0);
else if( x < 64)
HC595_OUT_satir(ascii1[x-32][col_index]);
else if( x < 96 )
HC595_OUT_satir(ascii2[x-64][col_index]);
else if( x < 128)
HC595_OUT_satir(ascii3[x-96][col_index]);

col_index++;
}
delay_us(120);
HC595_OUT_satir(0);
}
delaycount--;
}
startposition++;
} while(true);
}

bir yerinde sorun var ama çözemedim???? yardımcı olabilecek biri varmı???

05-30-2010 01:20 AM
Bu kullanıcının gönderdiği mesajları bul Bu mesajı bir cevapta alıntı yap
Mesaj Önizleme  Konuyu Gönder 

Yazdırılabilir Bir Versiyona Bak
Bu Konuyu Bir Arkadaşına Gönder
Bu Konuya Abone Ol | Konuyu Favorilerine Ekle

Foruma Git: