Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as C by sd ( 11 years ago )
/* http://i.imgur.com/8Fpok.jpg
*  both are on PORTD  
*  GPIO_0_D[8]  hc595 serial
*   ""     [10]   reg clock
*    ""    [12]   ser clock
*   ""     [18]  glcd RS
*          [20]       RW
*          [22]       E
**/

// glcd.c
/***GRAPHICAL INIT TEST****/

/*
 *
 * 2013  new  glcd rewrite
 *
 *
 *
 * */
void RW_low_RS_HIGH(){
 // omit rw since always supposed to be 0 
 _delay_us(10);
    PORT_gctrl = (1<< PD0) ;
    _delay_us(10);
    return;
}
void RW_low(){

 PORT_gctrl = (0 << PD1) ;
 return;
}
void RS_low(){

 PORT_gctrl = (0 << PD0) ;
 return;
}
void E_low(){
 
 PORT_gctrl = (0 << PD2) ;
 return;
}
void GLCD_STROBE_ENABLE(){

 _delay_us(10);
 PORT_gctrl = (1 << PD2) ;

 _delay_us(100);
 PORT_gctrl =  (0 << PD2) ;

 _delay_us(10);
 return;
}
void GLCD_write_CMD&#40;unsigned char command, unsigned char data&#41;{
 
 _delay_us(10);
 RW_low_RS_HIGH();
 
 _delay_us(10);
 send(command);
 shiftin();

 _delay_us(10);
 GLCD_STROBE_ENABLE();
 //RW_low(); 
 RS_low();

 _delay_us(10);
  send(data);
  shiftin();
  
  
  _delay_us(10);
     GLCD_STROBE_ENABLE();


return;
}

// hc595.c
 void clear(){
   //because mreset is hardwired high software clear
  
  send(0);
  // shiftin();
  
  return;
 }

void shiftin(){
  
  PORT_set = (1<<ST);
  CLK(Dclk);
  PORT_set = (1<<ST) | (1<<SH);
  CLK(Dclk);
   PORT_set = (0<<ST) | (1<<SH);
   CLK(Dclk);
  PORT_set = (0<<SH);
  CLK(Dclk);
 
 return;
 }

void send( unsigned char sch){


   static unsigned char count;


  for(count=0 ;count <8; count++){
  if( (sch & 0x80) == 0x80 ){
   CLK(Dclk);
   PORT_set = (1<<DS);
   CLK(Dclk);
   PORT_set = (1<<SH) | (1<<DS);
   CLK(Dclk); }
  
   else {
    CLK(Dclk);
   PORT_set = (0<<DS);
   CLK(Dclk);
   PORT_set = (1<<SH) | (0<<DS);
   CLK(Dclk);
   }
  sch = sch << 1;
  
  
  PORT_set = (0<<DS) | (1<<SH);
  CLK(Dclk);
   PORT_set = (0<<DS);
  }
  
  return ;

 }

 

Revise this Paste

Parent: 59947
Your Name: Code Language: