Hi James, the link "this version" is to the generic code on buydisplay.com. That code has a bit-bang SPI driver in it. Here's the pieces of interest from that link:
#define CS1 P3_5
#define RS P3_3
sbit SDA=P1^7;
sbit SCK=P1^6;
#pragma disable
void Write_Data(unsigned char dat)
{
unsigned char idata i;
RS=1;
SCK=0;
CS1=0;
Delay(10);
for(i=0;i<8;i++)
{
SCK=0;
_nop_();
_nop_();
SDA=dat&0x80;
dat=dat<<1;
_nop_();
_nop_();
SCK=1;
_nop_();
_nop_();
}
CS1=1;
Delay(5);
return;
}
#pragma disable
void Write_Instruction(unsigned char idata cmd)
{
unsigned char idata i;
RS=0;
SCK=0;
CS1=0;
Delay(10);
for(i=0;i<8;i++)
{
SCK=0;
_nop_();
_nop_();
SDA=cmd&0x80;
cmd=cmd<<1;
_nop_();
_nop_();
SCK=1;
_nop_();
_nop_();
}
CS1=1;
Delay(5);
return;
}
Here's my quick translation to the mbed code - but I didn't compile this, so it might need a little more change to make it work. You'll need to map the right p21-p24 pins for instance. Also, the _nop_() are intended to create a very small delay. I don't know if that is truly needed, but for the mbed delay_us() could be used - you might try some different values in the range of 1 to 100.
DigitalOut CS1(p21); // #define CS1 P3_5
DigitalOut RS(p22); //#define RS P3_3
DigitalOut DSA(p23); // sbit SDA=P1^7;
DigitalOut SCK(p24); // sbit SCK=P1^6;
// #pragma disable
void Write_Data(unsigned char dat)
{
unsigned char i; // unsigned char idata i;
RS=1;
SCK=0;
CS1=0;
delay_ms(10); // Delay(10);
for(i=0;i<8;i++)
{
SCK=0;
delay_us(10); // _nop_();
// _nop_();
SDA=dat&0x80;
dat=dat<<1;
delay_us(10); // _nop_();
// _nop_();
SCK=1;
delay_us(10); // _nop_();
// _nop_();
}
CS1=1;
delay_ms(5); // Delay(5);
return;
}
Make the same changes to the Write_Instruction().
Hopefully this will get you close enough to see something happen and take it from there.
I need some help porting test code for a graphic LCD into mbed. The display is like this one and are also available through CrystalFontz.
http://www.ebay.com/itm/2-1-128x64-Graphic-LCD-Module-Parallel-Serial-SPI-SPLC501-Black-White-Arduino-/301052582832?pt=LH_DefaultDomain_0&hash=item461821dbb0
I have it setup as 8-bit parallel. I am using the same pins as the text LCD that also runs on 8-bit parallel. My pinout is:
TextLCD lcd(p21, p22, p23, p24, p25, p26, p30, 8, 2); (rs, rw, e, d0, d1, d2, d3, n_column, n_rows).
The manufacturer published some test code to display some characters and pictures.
http://www.buydisplay.com/download/democode/ERC12864-12.1_DemoCode_8bit_8080.txt
Looking at the code I Have modified the pin definition to match mine. I can not get this to compile without lots and lots of errors.
I would appreciate anyone that can help. I did not see this chip listed in the cookbook or I would have started there.
Thanks in Advance.