//========================== CLEAR DISPLAY ==============================================
void ClearDisplay(BYTE grayScale)
{
int ndx;
// Set Column Address
WriteCommand(0x15);
WriteCommand(0x00);
WriteCommand(0x3F);
// Set Row Address
WriteCommand(0x75);
WriteCommand(0x00);
WriteCommand(0x3F);
DISPLAY_D_C =1;
DISPLAY_CS_NOT =0;
for(ndx =0; ndx < 4096; ndx++)
{
LATE = grayScale;
DISPLAY_WR_NOT=0;
DISPLAY_WR_NOT=1;
}
DISPLAY_CS_NOT =0;
}
//====================================WRITE DATA =============================================
void WriteData(unsigned char data)
{
DISPLAY_D_C =1;//Data
DISPLAY_CS_NOT =0;//Enable Chip Select
LATE = data;
DISPLAY_WR_NOT=0;
DISPLAY_WR_NOT=1;//Write Strobe
DISPLAY_CS_NOT=1;//disable chip select
delay(1);
}
//===================================WRITE COMMNAD==============================================
void WriteCommand(BYTE command)
{
DISPLAY_D_C =0;// Command
DISPLAY_CS_NOT =0;//Enable Chip Select
LATE = command;
DISPLAY_WR_NOT=0;
DISPLAY_WR_NOT=1;//Write Strobe
DISPLAY_CS_NOT=1;//disable chip select
delay(1);
}
//==================================== OSRAM INIT ============================================
void OSRAM_Init(void)
{
unsigned char i,j;
//Assumption VCC_BAR supply is switched and stable(Controlled by Blackfin)
// OSRAM
delay(2);//wait untill Vdd is stable
// Do hardware Reset
DISPLAY_RST_NOT = 0;
delay(100);//wait for 100mS
DISPLAY_RST_NOT = 1;
//Send Display OFF command
WriteCommand(0xAE);
//Switch on 12v Power Supply
SWITCH_ON_5V = 1;//switch on 5v power supply
DISPLAY_PWR = 1;//Switch ON display Power (12V)
delay(100);//wait untill the 12v is stable
//Column Address
WriteCommand(0x15); /* Set Column Address */
WriteCommand(0x00); /* Start = 0 */
WriteCommand(0x3F); /* End = 127 */
//Row Address
WriteCommand(0x75); /* Set Row Address */
WriteCommand(0x00); /* Start = 0 */
WriteCommand(0x3F); /* End = 63 */
// Contrast Control
WriteCommand(0x81); /* Set Contrast Control */
WriteCommand(0x6D); /* 0 ~ 127 */
// Current Range
WriteCommand(0x86); /* Set Current Range 84h:Quarter, 85h:Half, 86h:Full*/
// Re-map
WriteCommand(0xA0); /* Set Re-map */
WriteCommand(0x41); /* [0]:MX, [1]:Nibble, [2]:H/V address [4]:MY, [6]:Com Split Odd/Even "1000010"*/
//Display Start Line
WriteCommand(0xA1); /* Set Display Start Line */
WriteCommand(0x00); /* Top */
//Display Offset
WriteCommand(0xA2); /* Set Display Offset */
WriteCommand(0x44); /* Offset 76 rows */
//Display Mode
WriteCommand(0xA4); /* Set DisplaMode,A4:Normal, A5:All ON, A6: All OFF, A7:Inverse */
// Multiplex Ratio
WriteCommand(0xA8); /* Set Multiplex Ratio */
WriteCommand(0x3F); /* 64 mux*/
// Phase Length
WriteCommand(0xB1); /* Set Phase Length */
WriteCommand(0x22); /* [3:0]:Phase 1 period of 1~16 clocks */
/* [7:4]:Phase 2 period of 1~16 clocks /* POR = 0111 0100 */
// Row Period
WriteCommand(0xB2); /* Set Row Period */
WriteCommand(0x46); /* [7:0]:18~255, K=P1+P2+GS15 (POR:4+7+29)*/
// Display Clock Divide
WriteCommand(0xB3); /* Set Clock Divide */
WriteCommand(0x91); /* [3:0]:1~16, [7:4]:0~16, 100Hz */
/* POR = 0000 0001 */
// VSL
WriteCommand(0xBF); /* Set VSL */
WriteCommand(0x0D); /* [3:0]:VSL */
// VCOMH
WriteCommand(0xBE); /* Set VCOMH */
WriteCommand(0x02); /* [7:0]:VCOMH, (0.53 X Vref = 0.53 X 15 V = 7.95V)*/
// VP
WriteCommand(0xBC); /* Set VP */
WriteCommand(0x10); /* [7:0]:VP, (0.67 X Vref = 0.67 X 15 V = 10.05V) */
//---
// Gamma
WriteCommand(0xB8); /* Set Gamma with next 8 bytes */
WriteCommand(0x01); /* L1[2:1] */
WriteCommand(0x11); /* L3[6:4], L2[2:0] 0001 0001 */
WriteCommand(0x22); /* L5[6:4], L4[2:0] 0010 0010 */
WriteCommand(0x32); /* L7[6:4], L6[2:0] 0011 1011 */
WriteCommand(0x43); /* L9[6:4], L8[2:0] 0100 0100 */
WriteCommand(0x54); /* LB[6:4], LA[2:0] 0101 0101 */
WriteCommand(0x65); /* LD[6:4], LC[2:0] 0110 0110 */
WriteCommand(0x76); /* LF[6:4], LE[2:0] 1000 0111 */
// Set DC-DC
WriteCommand(0xAD); /* Set DC-DC */
WriteCommand(0x02); /* 03=ON, 02=Off */
// Display ON/OFF
WriteCommand(0xAF); /* AF=ON, AE=Sleep Mode */
}