
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
I connected a Nokia 3310 LCD display to the C-Control. I had to convert 5 to 3 V using a LM317 and a 74HC245. The display is quite dumb in terms of characters etc. It is just a graphical display and character sets must be loaded in the microcontroller itself. The display is controlled using SPI protocol. Quite simple: data is clocked in to the data input each high->low cycle of the clock. As a demonstration I donwloaded a bitmap on the display as can be seen on picture. For your interest, the source code: '-------------------------- '------ I/O PORTS --------- '-------------------------- ' 1 vdd ' 2 sclk ' 3 sdin ' 4 d/c ' 5 sce ' 6 gnd ' 7 vout ' 8 res define nok_sclk port[13] define nok_sda port[12] define nok_dc port[11] define nok_cs port[10] define nok_res port[9] define i as byte define row as byte define column as byte define iloop as byte define oloop as byte define tmp as byte define tmp2 as byte define x as word define val as byte goto main '------ SHOW A HEX NIBBLE ------------------------- FUNCTION HEXNIBBLE(TEMP as byte) if TEMP<10 then put (TEMP+48) ELSE put (TEMP+55) END IF END FUNCTION '------------------------------------------------- '-- SHOW CONTENT OF VAL AS HEX VALUE - '------------------------------------------------- FUNCTION SHOW_HEX(VAL as byte) define TEMP as byte TEMP=VAL/16 HEXNIBBLE(TEMP) TEMP=VAL MOD 16 HEXNIBBLE(TEMP) END FUNCTION FUNCTION DELAY (DEL as byte) for oloop=0 to DEL '10ms steps for iloop=1 to 200 NEXT NEXT END FUNCTION function NLCD_Write (data as byte, mode as bit) put data ' Pull nok_dc true or false depending on mode if (mode) then nok_dc = true else nok_dc = false end if nok_cs = false ' Clock in 8 bits of data for i = 1 to 8 nok_sclk = false if (data and 80h) = 0 then nok_sda = false else nok_sda = true end if nok_sclk = true data = data shl 1 next i nok_cs = true End Function function NLCD_GotoXY (xnokia as byte, ynokia as byte) NLCD_Write( 40h or ( ynokia and 7h ), false) NLCD_Write( 80h or ( xnokia and 7fh ), false) end function function NLCD_Clear() ' Data bit is false nok_sda = false ' Data mode nok_dc = true nok_cs = false for row= 1 to 6 ' 6 rows for column = 1 to 84 ' 84 columns or "pages" for i=1 to 8 ' Clock for the 8 bits of the "page" nok_sclk = false nok_sclk = true next i next column next row end function function NLCD_Init() ' Set initial status of LCD pins nok_sclk = false nok_sda = false nok_dc = false nok_cs = false nok_res = false ' Toggle LCD Reset DELAY(1) nok_res = false DELAY(25) nok_res = true nok_cs = true ';; Extended commands NLCD_Write (21h, false) ';; LCD Vop NLCD_Write (c5h, false) ';; Temp coef NLCD_Write (6h, false) ';; LCD Bias 1:48 NLCD_Write (13h, false) ';; Standard commands NLCD_Write (20h, false) ';; Normal Mode NLCD_Write (0ch, false) ' Clear and position at top of LCD NLCD_Clear(); NLCD_GotoXY(0,0); end function #main NLCD_Init() ' NLCD_GotoXY (0,0) FOR x = 1 TO 504 val = Looktab(bmp_table,x) NLCD_Write(val,true) next x end Table bmp_table 00 00 00 00 00h F8h F8h 60h 80h F8h F8h 00h C0h E0h 20h 20h E0h C0h 00h F8h F8h 80h C0h 60h 20h 00h E8h E8h 00h 40h A0h A0h E0h C0h 00h 00h 00h 00h 10h 18h 48h F8h B0h 00h 10h 18h 48h F8h B0h 00h 60h 30h F8h F8h 00h 00h F0h F8h 08h F8h F0h 00h 00h 00h 00h F8h F8h 00h 00h 00h 00h 00h E0h F0h 18h 08h 08h 18h 10h 00h F8h F8h 08h 08h F8h F0h 00h 00h 00h 07h 07h 00h 01h 07h 07h 00h 03h 07h 04h 04h 07h 03h 00h 07h 07h 01h 03h 87h 84h 80h 07h 07h 00h 03h 07h 04h 07h 07h 80h 80h 80h 00h 02h 06h 04h 07h 03h 00h 02h 06h 04h 07h 03h 00h 00h 80h 07h 07h 00h 00h 03h 07h 04h 07h 03h 00h 00h 00h 80h 07h 07h 04h 04h 84h 04h 00h 01h 03h 06h 84h 04h 06h 82h 80h 87h 07h 04h 04h 07h 03h 00h 00h 00h 00h 3Ch 42h 42h 42h 3Ch 00h 7Eh 02h 02h 02h 7Ch 00h 00h 00h 00h 1Eh 21h 40h 40h 40h 21h 00h 10h 10h 10h 00h 1Eh 21h 40h 40h 40h 21h 00h 3Ch 42h 42h 42h 3Ch 00h 7Eh 02h 02h 02h 7Ch 02h 7Fh 42h 00h 7Eh 04h 02h 00h 3Ch 42h 42h 42h 3Ch 00h 7Fh 00h 00h 00h 00h 7Fh 03h 1Ch 60h 1Ch 03h 7Fh 00h 41h 60h 50h 48h 47h 00h 00h 00h 00h 00h 00h 01h 01h FFh 00h C0h 70h 18h 08h 08h 18h 30h E0h 80h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 80h 80h 80h 80h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 01h 01h FFh 1Eh 03h 00h 00h 00h 00h 00h 00h 00h 07h 1Ch F0h 80h 00h 00h 00h 00h 00h 00h 00h 80h E0h 38h 0Eh 03h 01h 00h 00h 00h 00h 01h 01h 06h 18h 70h C0h 80h 00h 00h 80h F0h 10h 18h 08h 08h 18h 10h 60h 40h 00h 00h 00h 00h 80h 40h 40h 40h 40h 80h 00h 00h 80h 40h 40h 40h 80h 00h 00h 00h 00h 00h 00h C0h 00h C0h 40h 40h 40h 40h 80h 00h 81h 81h FFh 80h 80h 80h 80h 80h 80h 80h E0h 80h 80h 80h 80h 83h 82h 82h E6h 84h 86h 82h 81h 81h 80h 80h E0h 80h 80h 80h 80h 80h 80h 80h E0h 80h 80h 80h 80h 81h 81h 81h E0h 80h 80h 80h 80h 80h 80h 80h E0h 80h 80h 80h 00h 00h 11h 22h 22h 24h 24h 18h 00h 0Fh End Table |
| Antwort schreiben |