Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/09/12 11:01
Read: times


 
#187646 - help me with 93c46 and at89s52---MikroC
Responding to: ???'s previous message
here is my code for MikroC -
...
//define OP code for Group 1
unsigned char OP_read  = 0x80;	// 2 bit OP + 7 bit address  (DI =1 already)
unsigned char OP_erase = 0xC0;	// 2 bit OP + 7 bit address
unsigned char OP_write = 0x40;	// 2 bit OP + 7 bit address

//define OP code for Group 2
unsigned char OP_EW_enable  = 0x30;	// 4 bit OP + 5 bit X
unsigned char OP_EW_disable = 0x00;	// 4 bit OP + 5 bit X
unsigned char OP_erase_ALL  = 0x20;	// 4 bit OP + 5 bit X
unsigned char OP_write_ALL  = 0x10;	// 4 bit OP + 5 bit X


//define pin
sbit CS at P3.B7;
sbit SK at P3.B6;
sbit DI	at P3.B5;
sbit DO at P3.B4;

unsigned char i,indata,op_h,DT,addr,dta,out_data;
//unsigned char dis_code[] = { 0x28, 0x7E, 0xA2, 0x62,0x74, 0x61, 0x21, 0x7A,0x20, 0x60,0xff};
unsigned char Shift_Left[] = {0xFE, 0xFD, 0xFB, 0xF7,0xEF, 0xDF, 0xBF, 0x7F,};
//unsigned char display[] = {0xff,0xF0,0x0F,0x08,0x09,0xFF,0x05,0x50};

unsigned char dis_code = 0xA2;
//unsigned char Shift_Left = 0x7F;
unsigned char display;

//Group 2
void OP_G2(unsigned char op_h)
{ DI = 1; CS=1; SK=0;
  Delay_ms(2);
  SK=1;
  Delay_ms(2);
  SK=0;
  for(i=0;i<9;i++)
    { DI = (op_h & 0x80);
      SK=1;
      Delay_ms(2);
      op_h <<= 1;
      SK=0;
    }
    Delay_ms(10);

}

void standby(){CS= 0;SK=0;DI=0;}

//Group 1

void OP_G1(unsigned char op_h,unsigned char DT)
{
     DI = 1; CS=1; SK=0;
     Delay_ms(2);
     SK=1;
     Delay_ms(2);
     SK=0;
    i=0;
    while(i<2)
    {
      DI = (op_h & 0x80);
      SK=1;
      Delay_ms(2);
      op_h <<= 1;
      SK=0;
      i++;
    }
    DT<<=1;
    i=0;
    while(i<8)
    {
      DI = (DT & 0x80);
      SK=1;
      Delay_ms(2);
      DT <<= 1;
      SK=0;
      i++;
    }
    DI=0;
}

//---------------------writing-------------

void Into_Chip(unsigned char oph)
{  i=0;
   while(i<8)
    {
      DI = (oph & 0x80);
      SK=1;
      Delay_ms(2);
      oph <<= 1;
      SK=0;
      i++;
    }
}

void WR_Chip(unsigned char addr,unsigned char dta)
{
    OP_G1(OP_write, addr);
    Into_Chip(dta);
    CS=0;
    delay_ms(10);

}


//---------------------reading-------------

unsigned char OUT_Chip()
{
    unsigned char dtt=0;
    i=0;
    while(i<8)
    {   SK = 1;
        dtt |= DO;
        Delay_ms(2);
        SK=0;
        dtt <<= 1;
        i++;
    } //P0=dtt;
    //Delay_ms(500);
    return dtt;
    //P0=dtt;

}


void main()
{  OP_G2(OP_EW_enable); 
   CS=0;
   P0=0x7E;
   P2=0xFE;
   Delay_ms(1000);
   OP_G2(OP_erase_ALL);  
    // CS=0;
    //Delay_ms(1000);
   //OP_G2(OP_write_ALL); CS=0;
   //for(i = 0 ; i < 8; i++)
           WR_Chip(0, dis_code);

   //OP_G2(OP_EW_disable);

   //for(i = 0 ; i < 8; i++){
         OP_G1(OP_read, 0);
         display= OUT_Chip();
       //  }
   standby();

    while(1)
   {
     P2=0xff ;
     for(i=0; i<8; i++)
     {
          P0=display;
          P2=Shift_Left[i];
          delay_ms(400);
     }
   }
}


 



List of 20 messages in thread
TopicAuthorDate
help me with 93c46 and at89s52---MikroC            01/01/70 00:00      
   What You Need to Do Yourself            01/01/70 00:00      
      need help - 93c46 using AT89s52 - mikroc            01/01/70 00:00      
         MikroC is unwise choice            01/01/70 00:00      
   help me with 93c46 and at89s52---MikroC            01/01/70 00:00      
      So check without scope - adjust code until testable            01/01/70 00:00      
         you have now 3 times asked help with 93c46/at89s52--MikroC            01/01/70 00:00      
            93c46/at89s52--MikroC            01/01/70 00:00      
               my suggestion            01/01/70 00:00      
               You have already been given suggestions            01/01/70 00:00      
                  help me with 93c46 and at89s52---MikroC            01/01/70 00:00      
                     Use a proper Compiler            01/01/70 00:00      
                        I wanna, I wanna, I wanna,            01/01/70 00:00      
                     Time to actually prove your logic and your delays            01/01/70 00:00      
                        ----thanks all for helping out            01/01/70 00:00      
                           do you REALLY expect ....            01/01/70 00:00      
                     If you can't get MikroC to work ...            01/01/70 00:00      
                        switching to keil            01/01/70 00:00      
                           Example code on this website            01/01/70 00:00      
                           why, oh why            01/01/70 00:00      

Back to Subject List