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 CCS Technical Support

Need help on Samsung VFD LCD Display 20T202DA2JA

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



Joined: 12 Aug 2011
Posts: 1

View user's profile Send private message

Need help on Samsung VFD LCD Display 20T202DA2JA
PostPosted: Fri Aug 12, 2011 8:25 am     Reply with quote

Hi;
I have Samsung 5 pin 20x2 VFD. It use SPI communication.

[url="I bought on eBay"] http://cgi.ebay.com/20X2-Serial-SAMSUNG-VFD-LCD-Module-Display-20T202DA2JA-/190409174276?pt=LH_DefaultDomain_0&hash=item2c55456d04 [/url]

Seller Test code not running CCS C and pic 16F876:
Code:

//M68 8bit-4bit interface

#include <AT89X51.H>

#define STB  P2_1
#define SCLK P2_4
#define SDATA P2_0

unsigned char bdata data_byte;
sbit bit7=data_byte^7;
sbit bit6=data_byte^6;
sbit bit5=data_byte^5;
sbit bit4=data_byte^4;
sbit bit3=data_byte^3;
sbit bit2=data_byte^2;
sbit bit1=data_byte^1;
sbit bit0=data_byte^0;

unsigned char i,j,k;

unsigned char code UDF[13][8]=
{
 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
};

unsigned char code Seril_Demo_Line1[]={
' ',' ',' ',' ','V','F','D','-','D','I','S','P','L','A','Y',' ',' ',' ',' ',' ',
};
unsigned char code Seril_Demo_Line2[]={
'M','O','D','E',':','S','E','R','I','A','L','-','D','E','M','O',' ',' ',' ',' ',
};



void delay(unsigned int t)
{
 while(t--);
}

void code_send(unsigned char display_data_byte)
{
 data_byte=display_data_byte;

 SDATA=bit7; SCLK=0; SCLK=1;
 SDATA=bit6; SCLK=0; SCLK=1;
 SDATA=bit5; SCLK=0; SCLK=1;
 SDATA=bit4; SCLK=0; SCLK=1;
 SDATA=bit3; SCLK=0; SCLK=1;
 SDATA=bit2; SCLK=0; SCLK=1;
 SDATA=bit1; SCLK=0; SCLK=1;
 SDATA=bit0; SCLK=0; SCLK=1;
 
 delay(1);           //delay 40us at least, according to the SPEC 
}

void S_data_send(unsigned char temp_1)
{
 STB=0;
 code_send(0xfa);
 code_send(temp_1);
 STB=1;
}

void S_COM_send(unsigned char temp_2)
{
 STB=0;
 code_send(0xf8);
 code_send(temp_2);
 STB=1;
}

void main(void)
{
 S_COM_send(0x01);   //clear all display and set DD-RAM address 0 in address counter
 S_COM_send(0x02);   //move cursor to the original position
 S_COM_send(0x06);   //set the cursor direction increment and cursor shift enabled
 S_COM_send(0x38);   //set 8bit operation,2 line display and 100% brightness level
 S_COM_send(0x80);   //set cursor to the first position of 1st line
 S_COM_send(0x0c);   //set display on,cursor on,blinking off
 delay(10);

 for(j=0;j<13;j++)
 {
 /*********************************/
 
  S_COM_send(0x40);  //CGRAM ADDRESS SETTING

  for(k=0;k<8;k++)
  {
   S_data_send(UDF[j][k]);
  }
 /*********************************/

  S_COM_send(0x80);  //DDRAM ADDRESS SETTING

  for(i=0;i<80;i++)
  {
   S_data_send(0x00);
  }
 /*********************************/
 
  delay(20000);
 }


 S_COM_send(0x80);
 for(i=0;i<20;i++)
 {
  S_data_send(Seril_Demo_Line1[i]);
 }

 S_COM_send(0xc0);
 for(i=0;i<20;i++)
 {
  S_data_send(Seril_Demo_Line2[i]);
 }
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);
 delay(50000);

 /*********************************/

 S_COM_send(0x80);  //DDRAM ADDRESS SETTING

 for(i=0;i<20;i++)
 {
  S_data_send(0x2a);
  S_data_send(0x20);
 }
 for(i=0;i<20;i++)
 {
  S_data_send(0x20);
  S_data_send(0x2a);
 }
 delay(50000);
 delay(50000);
 /*********************************/

 S_COM_send(0x80);  //DDRAM ADDRESS SETTING

 for(i=0;i<20;i++)
 {
  S_data_send(0x20);
  S_data_send(0x2a);
 }
 for(i=0;i<20;i++)
 {
  S_data_send(0x2a);
  S_data_send(0x20);
 }
 delay(50000);
 delay(50000);
 /*********************************/

 S_COM_send(0x40);  //CGRAM ADDRESS SETTING

 for(k=0;k<8;k++)
 {
  S_data_send(0xff);
 }
 
 S_COM_send(0x80);  //DDRAM ADDRESS SETTING

 for(i=0;i<80;i++)
 {
  S_data_send(0x00);
 }

 while(1);
}


Help me pls. Who have working code, sharing pls.
Excuse me my bad english.
Regards.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Aug 12, 2011 9:25 am     Reply with quote

The code is obviously delay sensitive.

I do not know what the CCS compiler does but some compilers, when faced with this:

Code:
while(x--);


will optimize this code out completely. So no delay.

CCS had delay_us() and delay_ms() functions which will be far more accurate. Don't forget to the the #delay(clock=...) directive.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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