使用AT91SAM7S256驱动OLED屏,已经点亮但是不能刷显示图像的问题。
void oled_init(void){
*AT91C_PIOA_PER = OLED_DC|OLED_RES;
*AT91C_PIOA_OER = OLED_DC|OLED_RES;
*AT91C_PIOA_MDER = OLED_DC|OLED_RES;
RESET_ON();
for(i=0;i<500;i++);
RESET_OFF();
oled_write_cmd(SWRESET);
oled_write_cmd(COMLCK);
oled_write_data(0x12);
oled_write_cmd(COMLCK);
oled_write_data(0xb3);
oled_write_cmd(SLPIN);
oled_write_cmd(CASET);//set column address
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RASET);//set raw address
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(SDCOSCF);//set clock
oled_write_data(0x1a);
oled_write_cmd(MADCTL); //memory access control
oled_write_data(0x08);
oled_write_data(0x00);
oled_write_cmd(SETMUX); //set mux ratio
oled_write_data(0x7f);
oled_write_cmd(SETDO); //set display offset and when MADCTL bit7 = 0,display start line is seted
oled_write_data(0x00);
oled_write_cmd(GPIO); //set GPIO
oled_write_data(0x00);
oled_write_cmd(COLMOD);
oled_write_data(0x05); //(101)b :65k pixel color 16bit/pixel
oled_write_cmd(TEON);
oled_write_data(0x00);
oled_write_cmd(FUSEL);
oled_write_data(0x03);
oled_write_cmd(0xba);
oled_write_data(0x80);
oled_write_cmd(0xbb);
oled_write_data(0x80);
oled_write_cmd(0xbc);
oled_write_data(0x80);
oled_write_cmd(SETLUM);
oled_write_data(0xf0);
oled_write_cmd(LINGLUT);
oled_write_cmd(GLUT);
for(i=0;i<96;i++)
{
oled_write_data(Gamma_Table); //Gamma_Table
}
oled_write_cmd(PHLEN);
oled_write_data(0x32);
oled_write_cmd(VPSET);
oled_write_data(0x09);
oled_write_cmd(SECPLEN);
oled_write_data(0x0B);
oled_write_cmd(SSPS);
oled_write_data(0x03);
oled_write_cmd(SETVCOMH);
oled_write_data(0x04);
oled_write_cmd(DISPON);
oled_write_cmd(INVOFF);
oled_write_cmd(NORON);
oled_write_cmd(RAMWR);
oled_write_cmd(SLPOUT);
}
void oled_write_cmd(char cmd)
{
CMD_ON();
spi_send(cmd);
DATA_ON();
}
void oled_write_data(char data)
{
DATA_ON();
spi_send(data);
DATA_ON();
}
void Oled_SetRowColumn_Lcd(RECT *rect)//设置显示范围
{
oled_write_cmd(CASET); //column set
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RASET); //row set
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RAMWR); // start memory write
}
void oled_show_wh(void)//全部显示白色
{
int y,x;
RECT pp;
pp.h = 127; //窗口测试
pp.w= 127;
pp.x = 0;
pp.y=0;
Oled_SetRowColumn_Lcd(&pp);
for(y=0;y<128;y++)
{
for(x=0;x<128;x++)
{
oled_write_data(0xff);
oled_write_data(0xff);
}
}
oled_write_cmd(NOP); // end memory write
}
用示波器测量,SPI数据是能够正常发送的。其中CS,D/C,的时序也是正常。
点亮后,能够控制 ALL PIXES ON/OFF。
但是想要刷GDDRAM的数据,却没有响应,只是显示雪花状态。
对了,屏幕的尺寸大小是128×128的
以下附上芯片资料 点击此处下载 ourdev_639544N72VBD.pdf(文件大小:1.54M) (原文件名:SSD1355_1.2.pdf)
点击此处下载 ourdev_639545XY5718.pdf(文件大小:1.20M) (原文件名:SAS1-D036-A UG-2828GDEDF06-Univision.pdf)
点击此处下载 ourdev_639546MW00LV.pdf(文件大小:503K) (原文件名:AT91SAM7S256.pdf)
这些是OLED资料和MCU资料
希望论坛中的朋友能够给予帮助,不胜感激 采用模拟SPI功能来驱动OLED屏幕,问题已经解决。
原来程序使用的是硬件SPI功能,在时序上可能没有符合手册要求。
模拟SPI函数如下:
void Write_Data(unsigned char Data) //模拟SPI发送
{
unsigned char i;
CS_0;
DC_1;
for (i=0; i<8; i++)
{
SCLK_0;
if((Data&0x80)>>7)
{
SDIN_1;
}
else
{
SDIN_0;
}
Data = Data << 1;
SCLK_1;
// uDelay(1);
}
// SCLK=0;
DC_1;
CS_1;
}
页:
[1]