Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sed_init(void) {
- SED_PORT_DATA = 0xff;
- //DDR(SED_PORT_DATA) = 0xff;
- sed_data_out();
- SED_DDR_CTRL |= (1<<SED_PIN_RST | 1<<SED_PIN_CS | 1<<SED_PIN_WR | 1<<SED_PIN_RD | 1<<SED_PIN_A0);
- SED_PORT_CTRL |= (1<<SED_PIN_RST | 1<<SED_PIN_CS | 1<<SED_PIN_WR | 1<<SED_PIN_RD | 1<<SED_PIN_A0);
- // Reset :)
- delay1ms(20);
- //sed_cs_control = SED_CS_CTRL_AUTO;
- sed_set_cs();
- sed_set_rd();
- sed_set_wr();
- sed_clr_rst();
- delay1ms(5); // min. 200us
- sed_set_rst();
- delay1ms(10);
- // SYSTEM SET
- sed_command(0x40); // system set
- // P1:
- // *[0] M0 (0x01) - 0=Internal CG ROM, 1=External
- // *[1] M1 (0x02) - 0=CG RAM1 32char, 1=64char CG RAM + CG RAM2
- // *[2] M2 (0x04) - 0=8px char height , 1=16px char height <- External CG ROM
- // *[3] W/S (0x08) - 0=Single panel LCD , 1=Dual panel LCD
- // *[4] 1 (0x10) - 1= Always 1...
- // *[5] IV (0x20) - 0=Screen top-line correction , 1=No correction
- // *[6] TL (0x40) - 0=LCD Mode , 1=TV Mode (Only SED1336 ?)
- // *[7] DR (0x80) - 0=Normal , 1=Additional Shift clock cycles
- sed_data(0x10|0x20); // M2:M0=000, WS=0, IV=1, TL=0, DR=0
- // P2:
- // *[2:0] FX (0x00...0x07) - Character field width + 1 (1...8)
- // *[7] WF (0x80) - 0=16line AC Drive, 1=Two-frame AC Drive
- sed_data(0x80|7); // FX=7 (8px) or FX=5 (6px), WF=0 ::: FX >= DisplayWidth / CharsPerLine
- // P3:
- // *[3:0] FY (0x00...0x0F) - Height in pixels of character + 1 (1...16)
- sed_data(7); // FY=7 (8px)
- // P4:
- // *[7:0] CR (0x00...0xEF - 0...239) - "Section 3.2.1.12" ::: CR=RND(FX / 8) * CharsPerLine
- sed_data(49); //50
- // P5:
- // *[7:0] TCR (0x00...0xFF - 1...256) - must be: >= CR+4
- #define SED_TCR_VALUE 54
- sed_data(SED_TCR_VALUE); // P5
- // P6:
- // *[7:0] LF (0x00...0xFF) - Height in lines of frame, height=LF+1
- #define SED_LF_VALUE 160
- sed_data(SED_LF_VALUE); // LF=(239+2=dummy lines)+1=242
- // P7 & P8 - AP - horizontal address range = 256 = 0x0100 => [15:8-7:0] 0x01-0x00
- // *[15:0] AP - horiontal address range of the virtual screen (same as CR??)
- #define SED_AP_GRAPH (uint16_t)50
- #define SED_APL_GRAPH (SED_AP_GRAPH&0xff)
- #define SED_APH_GRAPH (SED_AP_GRAPH>>8)
- sed_data(SED_APL_GRAPH); // P7 - AP Low
- sed_data(SED_APH_GRAPH); // P8 - AP High
- #if (SED_XTAL/((SED_TCR_VALUE*9+1)*SED_LF_VALUE)) < 50
- #warning "SED1330 Crystal Oscillator Frequency is too low, lcd screen might flicker!"
- #endif
- // Memory map:
- // TEXT: Chars per display: 50*20=1000chars (bytes) per display
- // GRAPH: ((400*160)/8) = 8000bytes
- // SAD1 :> dispaly 1, Layer 1 ( TEXT ) - 20rows, 50char = 1000chars per panel
- // SAD2 :> display 1, Layer 2 ( Graphic ) ; 160 rows, 400cols = 64000 / 8bits = 8000 bytes per panel
- // SAD3 :> display 2, Layer 1 ( TEXT )
- // SAD4 :> display 2, Layer 2 ( Graphic ) - INVALID FOR THIS PANEL (WS=0)
- sed_command(0x44); // Scroll
- // P1:P2 = SAD1 L:H
- sed_data(SED_SAD1L); // P1
- sed_data(SED_SAD1H); // P2
- // P3 - SL1 - Screen block start address - numbers of lines per display
- sed_data(SED_SL); // P3
- // P4:P5 = SAD2 L:H
- sed_data(SED_SAD2L); // P4
- sed_data(SED_SAD2H); // P5
- // P6 - SL2 - same as SL1
- sed_data(SED_SL); // P6
- // P7:P8 = SAD3 L:H
- sed_data(SED_SAD3L); // P7
- sed_data(SED_SAD3H); // P8
- // P9:P10 = SAD4 L:H
- sed_data(SED_SAD4L); // P9
- sed_data(SED_SAD4H); // P10
- sed_command(0x5A); // HDOT SCR
- sed_data(0x00); // 0=no horizontal scroll of display
- sed_command(0x5B); // OVLAY
- // MX0,MX1 = [0:1] 0,0 0x00=OR (0x00) [ L1 | L2 | L3 ]
- // MX0,MX1 = [0:1] 0,1 0x01=EX-OR (0x01) [ (L1 ^ L2) | (L3 ^ L4) ] // L2 and L4 equal?
- // MX0,MX1 = [0:1] 1,0 0x02=AND (0x02) [ (L1 & L2) | (L3 & L4) ]
- // MX0,MX1 = [0:1] 1,1 0x03=PriorityOR (0x03) [ L1 > L2(L4??) > L3)
- // DM1,DM2 = [2:3] 0,0 0x00=Text mode for Layer 1 and 3 (Layer 1 Upper panel, Layer 1 lower panel) (0x00)
- // DM1,DM2 = [2:3] 1,1 0x0c=Graphic mode for Layer 1 and 3 (Layer 1 Upper panel, Layer 1 lower panel) (0x0C)
- // OV = [4] 0 - Mixed mode (text+graph), two layer (0x10)
- sed_data(0x00);
- sed_command(0x58); // disp ON/OFF => disable screen
- // FC0,1 = [0:1] (0x01,0x02) - cursor flash rate
- // FP0,1 = [2:3] (0x04,0x08) - SAD1 ON/OFF + flashing
- // FP2,3 = [4:5] (0x10,0x20) - SAD2,4 ON/OFF + flashing
- // FP4,5 = [6:7] (0x40,0x80) - SAD3 ON/OFF + flashing
- sed_data(0x04|0x10); // SAD1, SAD2&4, SAD3 = ON
- sed_command(0x5D); // CSR FORM
- sed_data(7); // CRX <= FX - cursor width (8px - same as char width)
- //sed_data(0x87); // CRY = FY-1 - cursor height (8px - same as char height) ; CM=1 - block cursor
- sed_data(0x80|7); // CRY = FY-1 - cursor height (8px - same as char height) ; CM=0 - line cursor
- sed_command(0x4C); // CSRDIR - Cursor move in right dir.
- // "zero" whole memory
- sed_command(SED_DRAW_CSRW);
- sed_data(0); sed_data(0);
- sed_command(SED_MEM_MWRITE);
- for (uint16_t t=0;t<0x8000;t++) sed_data(0); // wipe 32k memory
- // for the end switch back on display
- sed_command(0x59); // disp ON/OFF => DISP_ON
- // FC0,1 = [0:1] (0x01,0x02) - cursor flash rate
- // FP0,1 = [2:3] (0x04,0x08) - SAD1 ON/OFF + flashing
- // FP2,3 = [4:5] (0x10,0x20) - SAD2,4 ON/OFF + flashing
- // FP4,5 = [6:7] (0x40,0x80) - SAD3 ON/OFF + flashing
- sed_data(0x04|0x10); // SAD1, SAD2&4
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement