n2roy
Newbie level 3
Experts plz solve my led display problem (.at89s52 with keil C source code + proteus)
I was trying to builds a 16 X 72 led Display, but im stuck on programing. In Proteus simulation led message going smoothly but In real Mcu project its not which i expect, Led message is running but Shaken, may be its for low refresh rate. How to get more Refresh rate...
here is source code:
=====================
- - - Updated - - -
here is schematic of that project...
I was trying to builds a 16 X 72 led Display, but im stuck on programing. In Proteus simulation led message going smoothly but In real Mcu project its not which i expect, Led message is running but Shaken, may be its for low refresh rate. How to get more Refresh rate...
here is source code:
=====================
Code:
/* The current program led matrix 16x64
#include "regx52.h"
#include "font_code.h"
#define scan_led P2
/////////////////////////////
//////Initial setup//////
#define so_led 8 // multiple of 8
#define so_hang 16 // the height of the font
#define multi so_hang+1 //
#define cot_font 11 // width font
#define en_run 1
////////////////////////////
typedef unsigned char uchar;
typedef unsigned int uint;
sbit rck=P3^2;
sbit srck=P3^0;
sbit ser_in=P3^1;
sbit en_hc154=P3^3;
bit run=0,en=en_run;
idata uchar display_buffer[so_hang][so_led];
idata uchar shift_buffer[so_hang];
uchar row_buffer[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar row_led[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
uchar tocdoh=0xf6,tocdol=0x00;
uchar kitu_code=0;
char row=multi;
void shift_dataled();
void test_led();
void clear_buffer();
void run_string();
void copy_datacode();
void scan_dataled_code();
void init_interrupt();
////////////////////////////////
/////// Timer 0 ////////////
void isr_timer0() interrupt 1 using 1
{
TH0=tocdoh,TL0=tocdol;
if(--row==-1) row=multi-1;
shift_dataled();
if(row==so_hang) run=1;
}
////////////////////////////////
/////////The main program/////
void main()
{
uchar w;
init_interrupt();
test_led();
clear_buffer();
if(en==0) scan_dataled_code();
while(1)
{
if((run==1)&(en==1)){
IE&=0xfd;
run_string(),run=0;
if(++w==8) copy_datacode(),w=0;
row=so_hang;
IE|=0x02;
}
}
}
////////////////////////////////
//////// checking for problems led ////////////
void test_led()
{
uchar i,j;
uint t_delay=10000;
for(i=0;i<so_hang;i++)
for(j=0;j<so_led;j++)
display_buffer[i][j]=0xff;
while(--t_delay);
}
void clear_buffer()
{
uchar i,j;
for(i=0;i<so_hang;i++)
for(j=0;j<so_led;j++)
display_buffer[i][j]=0;
}
////////////////////////////////
///////translate data and scan LEDs////
void shift_dataled()
{
char i,j;
srck=0;
rck=0;
if(row<so_hang){
for(i=0;i<so_led;i++)
for(j=0;j<8;j++){
ser_in=display_buffer[row][i]&row_buffer[7-j];
srck=1;
srck=0;
}
en_hc154=1;
rck=1;
rck=0;
scan_led=row_led[row];
en_hc154=0;
}
}
void copy_datacode()
{
uchar i;
static uchar j;
for(i=0;i<so_hang;i++)
shift_buffer[i]=Bmp002[Bmp002[2]*i+3+j];
if(++j==Bmp002[2]) j=0;
}
////////////////////////////////
void run_string()
{
uchar i,j;
for(i=0;i<so_hang;i++)
{
for(j=0;j<so_led;j++)
{
display_buffer[i][j]<<=1;
if(j!=(so_led-1)) display_buffer[i][j]|=((display_buffer[i][j+1]&0x80)>>7);
else display_buffer[i][j]|=((shift_buffer[i]&0x80)>>7);
}
shift_buffer[i]<<=1;
}
}
void scan_dataled_code()
{
uchar i,j;
for(i=0;i<so_hang;i++){
for(j=0;j<so_led;j++){
display_buffer[i][j]=Bmp002[Bmp002[2]*i + 3+j];
}
}
}
////////////////////////////////
void init_interrupt()
{
TMOD=0x02; //timer0 mode 1 16b
TH0=0xF8;
TL0=0x30;
TR0=1;
TR1=1;
IE=0x82; //timer0 interrupt enable
}
- - - Updated - - -
here is schematic of that project...
Last edited by a moderator: