CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

moving message help needed

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joshinjoy



Joined: 18 Feb 2010
Posts: 1

View user's profile Send private message

moving message help needed
PostPosted: Thu Feb 18, 2010 10:53 pm     Reply with quote

I am in project of building moving message display.
One character is 16x16 led matrix there are total 6 characters.
So there are 16 rows and 96 columns.
The rows are connected with two 74ls595 shift registers and ULN2803
transistor array. Columns are connected to 74ls595 shift register.
I used 18f252. I used hardware MSSP SPI interface to 74ls595 .

My program works as this:
1st all the shift register loaded with data and that row is switched on.
Then again all the shift registers are loaded and second line is switched on.
This repeats.

My problem is the blinking of led is very much. How can I overcome it ?
I am linking my program. Anyone please help me.
Code:
 
#include <C:\Program Files\PICC\Devices\18f252.h>
#device adc=8

#FUSES NOWDT                  //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOOSCSEN                 //Oscillator switching is disabled, main oscillator is source
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES WRTC                     //configuration registers write protected
#FUSES NOCPD                    //No EE protection
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads

#use delay(clock=40000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#define   down_dat   PIN_B0
#define   down_clk   PIN_B2
#define   down_cs    PIN_B1

#define   shift_cs    PIN_C2

void down_send(int1 dat);
int16 modify(int16 value,int16 v_);
int16 load(int16 lding,int16 cur);
void nxt_char(void);
void select(void);
void nxt_ch2(void);

const int16 and[] = {
0b1000000000000000,0b0100000000000000,0b0010000000000000,
0b0001000000000000,0b0000100000000000,0b0000010000000000,
0b0000001000000000,0b0000000100000000,0b0000000010000000,
0b0000000001000000,0b0000000000100000,0b0000000000010000,
0b0000000000001000,0b0000000000000100,0b0000000000000010,
0b0000000000000001
};
//table of small letters
const int16 tabel_sm[] = {
0x001c,
0b0000000000000000,0b0000000000000000,0b0000000000000000,
0b0000000000000000,0b0000111111110000,0b0001111111111000,
0b0011111011111100,0b0011100000111100,0b0000000000111100,
0b0001111111111100,0b0011111111111100,0b0111110000111100,
0b0111100001111100,0b0111110001111100,0b0011111111111100,
0b0001111110011110,

0x0032,
0b0111100000000000,0b0111100000000000,0b0111100000000000,
0b0111100000000000,0b0111101111100000,0b0111111111111000,
0b0111111111111100,0b0111100000011110,0b0111100000011110,
0b0111100000011110,0b0111100000011110,0b0111100000011110,
0b0111100000011110,0b0111111000111100,0b0111111111111100,
0b0111101111110000,

0x0021,
0b0000000000000000,0b0000000000000000,0b0000000000000000,
0b0000000000000000,0b0000011111100000,0b0001111111111000,
0b0011111111111100,0b0011110000111110,0b0111100000000000,
0b0111100000000000,0b0111100000000000,0b0111100000000000,
0b0011110000011110,0b0011111000111100,0b0001111111111000,
0b0000011111110000
};

               
 int16 kk;

 int16 v1_1,v1_2,v1_3,v1_4,v1_5,v1_6;
 int16 v2_1,v2_2,v2_3,v2_4,v2_5,v2_6;
 int16 v3_1,v3_2,v3_3,v3_4,v3_5,v3_6;
 int16 v4_1,v4_2,v4_3,v4_4,v4_5,v4_6;

 int16 v5_1,v5_2,v5_3,v5_4,v5_5,v5_6;
 int16 v6_1,v6_2,v6_3,v6_4,v6_5,v6_6;
 int16 v7_1,v7_2,v7_3,v7_4,v7_5,v7_6;
 int16 v8_1,v8_2,v8_3,v8_4,v8_5,v8_6;

 int16 v9_1,v9_2,v9_3,v9_4,v9_5,v9_6;
 int16 v10_1,v10_2,v10_3,v10_4,v10_5,v10_6;
 int16 v11_1,v11_2,v11_3,v11_4,v11_5,v11_6;
 int16 v12_1,v12_2,v12_3,v12_4,v12_5,v12_6;

 int16 v13_1,v13_2,v13_3,v13_4,v13_5,v13_6;
 int16 v14_1,v14_2,v14_3,v14_4,v14_5,v14_6;
 int16 v15_1,v15_2,v15_3,v15_4,v15_5,v15_6;
 int16 v16_1,v16_2,v16_3,v16_4,v16_5,v16_6;

 int16 val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14,val15,val16;

 int16 t_dis[16];
 char joshii;
 int16 joshin;
 int16 rahul;
 unsigned char shij;
 int1 recv,flg;
 #bit SSPIF = 0xf9e.3
 #byte SSPBUF=0xFC9
 #byte STATUS = 0xFD8
 #bit c = STATUS.0


/*
 #int_RDA
RDA_isr()
{

}
*/

#int_SSP
void SSP_isr()
{
   SSPIF = 0;
      switch(kk)
      {
         case 0:
         {
            SSPBUF = ((v16_1 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 1:
         {
            SSPBUF = (v16_1 & 0x00ff) ;
            kk++;
            break;
         }
         
         case 2:
         {
            SSPBUF = ((v16_2 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 3:
         {
            SSPBUF = (v16_2 & 0x00ff);
            kk++;
            break;
         }
         
         case 4:
         {
            SSPBUF = ((v16_3 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 5:
         {
            SSPBUF = (v16_3 & 0x00ff);
            kk++;
            break;
         }
         
         case 6:
         {
            SSPBUF = ((v16_4 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 7:
         {
            SSPBUF = (v16_4 & 0x00ff);
            kk++;
            break;
         }
         
         case 8:
         {
            SSPBUF = ((v16_5 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 9:
         {
            SSPBUF = (v16_5 & 0x00ff);
            kk++;
            break;
         }
         
         case 10:
         {
            SSPBUF = ((v16_6 >> 8) & 0x00ff);
            kk++;
            break;
         }
         
         case 11:
         {
            SSPBUF = (v16_6 & 0x00ff);
            kk++;
            break;
         }
         
         case 12:
         {
            down_send(1);
            output_high(down_cs);
            output_low(down_cs);
           
            output_high(shift_cs);
            output_low(shift_cs);
            SSPBUF = (v15_1 >> 8) & 0x00ff;
           
            kk++;
            break;
         }
       
         case 13:
         {
            SSPBUF = (v15_1 & 0x00ff);
            kk++;
            break;
         }
         
         case 14:
         {
            SSPBUF = (v15_2 >> 8) & 0x00ff;
            kk++;
            break;
         }
         
         case 15:
         {
            SSPBUF = v15_2 & 0x00ff;
            kk++;
            break;
         }
         case 101:
         {
            SSPBUF = v8_3 & 0x00ff;
            kk++;
            break;
         }
         
         case 102:
         {
            SSPBUF =(v8_4 >> 8) & 0x00ff;
            kk++;
            break;
         }
         
         case 192:
         {
            down_send(0);
            output_high(down_cs);
            output_low(down_cs);
           
            output_high(shift_cs);
            output_low(shift_cs);
             SSPBUF = ((v16_1 >> 8) & 0x00ff);     
            kk=0;
 
            break;
         }
         
      }     
}
   
void main()
{
   int16 temp;//delay
   char k,j;//display position
 
   set_tris_b (0);
   set_tris_c (0b10000000); 
   output_low(down_cs);
   output_low(down_clk);
   
   output_low(shift_cs);
   
    kk = 0;
   joshii = 0;
   joshin = 0;
   rahul=0;
   recv = 0;
   shij = 0;
   flg = 1;
   
   v1_1=v1_2=v1_3=v1_4=v1_5=v1_6=0;
   v2_1=v2_2=v2_3=v2_4=v2_5=v2_6=0;
   v3_1=v3_2=v3_3=v3_4=v3_5=v3_6=0;
   v4_1=v4_2=v4_3=v4_4=v4_5=v4_6=0;

   v5_1=v5_2=v5_3=v5_4=v5_5=v5_6=0;
    v6_1=v6_2=v6_3=v6_4=v6_5=v6_6=0;
    v7_1=v7_2=v7_3=v7_4=v7_5=v7_6=0;
   v8_1=v8_2=v8_3=v8_4=v8_5=v8_6=0;

    v9_1=v9_2=v9_3=v9_4=v9_5=v9_6=0;
    v10_1=v10_2=v10_3=v10_4=v10_5=v10_6=0;
    v11_1=v11_2=v11_3=v11_4=v11_5=v11_6=0;
    v12_1=v12_2=v12_3=v12_4=v12_5=v12_6=0;

    v13_1=v13_2=v13_3=v13_4=v13_5=v13_6=0;
    v14_1=v14_2=v14_3=v14_4=v14_5=v14_6=0;
    v15_1=v15_2=v15_3=v15_4=v15_5=v15_6=0;
    v16_1=v16_2=v16_3=v16_4=v16_5=v16_6=0;
   
    //setup
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_64);
   //setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_64);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
  // setup_timer_2(T2_DIV_BY_1,5,1);
   setup_timer_2(T2_DISABLED,5,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   enable_interrupts(INT_RDA);
   enable_interrupts(INT_SSP);
   enable_interrupts(GLOBAL);
   setup_oscillator(False);
   
 
   //end set up
   
      SSPIF = 1;       
   
   k = 0;
   j = 0;
   
   for(temp=0;temp<16;temp++)
   t_dis[temp] = 0;
   
   for(;;)
   {
         val1   = ( t_dis[15]  & and[k] ) << j;
         val2   = ( t_dis[14]  & and[k] ) << j;
         val3   = ( t_dis[13]  & and[k] ) << j;
         val4   = ( t_dis[12]  & and[k] ) << j;
         val5   = ( t_dis[11]  & and[k] ) << j;
         val6   = ( t_dis[10]  & and[k] ) << j;
         val7   = ( t_dis[9]   & and[k] ) << j;
         val8   = ( t_dis[8]   & and[k] ) << j;
         val9   = ( t_dis[7]   & and[k] ) << j;
         val10  = ( t_dis[6]   & and[k] ) << j;
         val11  = ( t_dis[5]   & and[k] ) << j;
         val12  = ( t_dis[4]   & and[k] ) << j;
         val13  = ( t_dis[3]   & and[k] ) << j;
         val14  = ( t_dis[2]   & and[k] ) << j;
         val15  = ( t_dis[1]   & and[k] ) << j;
         val16  = ( t_dis[0]   & and[k] ) << j;
label:               
         nxt_char();
     
         delay_ms(1);
         
      k++;
      if (k == 16 || k == 17)
      {
         val1=val2=val3=val4=val5=val6=val7=val8=val9=val10=val11=val12=val13=val14=val15=val16= 0;
         goto label;
      }
      j++;
      if(k == 18)
      {
         k = 0;
         j = 0;   
         select();     
      }
         
   }
}

void nxt_char(void)
{
         v16_5 = modify(val1,v16_5);
         v16_4 = load(v16_5,v16_4);
         v16_3 = load(v16_4,v16_3);
         v16_2 = load(v16_3,v16_2);
         v16_1 = load(v16_2,v16_1);
               
         v15_5 = modify(val2,v15_5);
         v15_4 = load(v15_5,v15_4);
         v15_3 = load(v15_4,v15_3);
         v15_2 = load(v15_3,v15_2);
         v15_1 = load(v15_2,v15_1);
           
         v14_5 = modify(val3,v14_5);   
         v14_4 = load(v14_5,v14_4);
         v14_3 = load(v14_4,v14_3);
         v14_2 = load(v14_3,v14_2);
         v14_1 = load(v14_2,v14_1);   
         
         v13_5 = modify(val4,v13_5);
         v13_4 = load(v13_5,v13_4);
         v13_3 = load(v13_4,v13_3);
         v13_2 = load(v13_3,v13_2);
         v13_1 = load(v13_2,v13_1);
           
         v12_5 = modify(val5,v12_5);
         v12_4 = load(v12_5,v12_4);
         v12_3 = load(v12_4,v12_3);
         v12_2 = load(v12_3,v12_2);
         v12_1 = load(v12_2,v12_1);   
         
         v11_5 = modify(val6,v11_5);
         v11_4 = load(v11_5,v11_4);
         v11_3 = load(v11_4,v11_3);
         v11_2 = load(v11_3,v11_2);
         v11_1 = load(v11_2,v11_1);   
         
         v10_5 = modify(val7,v10_5);
         v10_4 = load(v10_5,v10_4);
         v10_3 = load(v10_4,v10_3);
         v10_2 = load(v10_3,v10_2);
         v10_1 = load(v10_2,v10_1);   
         
         v9_5  = modify(val8,v9_5);
         v9_4 = load(v9_5,v9_4);
         v9_3 = load(v9_4,v9_3);
         v9_2 = load(v9_3,v9_2);
         v9_1 = load(v9_2,v9_1);   
         
         v8_5  = modify(val9,v8_5);
         v8_4 = load(v8_5,v8_4);
         v8_3 = load(v8_4,v8_3);
         v8_2 = load(v8_3,v8_2);
         v8_1 = load(v8_2,v8_1);   
         
         v7_5  = modify(val10,v7_5);
         v7_4 = load(v7_5,v7_4);
         v7_3 = load(v7_4,v7_3);
         v7_2 = load(v7_3,v7_2);
         v7_1 = load(v7_2,v7_1);



+++++++++++++++++++++++
90% of code deleted.

Reason: Phpbb can not display it.

-- Forum Moderator
+++++++++++++++++++++++
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group