daily pastebin goal
49%
SHARE
TWEET

HALLÅ

a guest Dec 10th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void display_Initialise(void){
  2.         //INITIALISES PORTS C12-C19 TO COMMUNICATE WITH CHIP
  3.         //RESETS DISPLAY AND INITIATES GRAPHIC & TEXT
  4.  
  5.     //PORT ENABLE  C12-19                  check with PIO_PSR 0x400E1208
  6.     *((volatile unsigned int*)0x400E1200) = (0xFF << 12);
  7.    
  8.     //DISABLE INPUT DEBOUNCE
  9.     *((volatile unsigned int*)0x400E1224) = (0xFF00FF << 2);
  10.  
  11.     //SET OUTPUT DATA C12-C19
  12.     //74CHIP OE = 1, 74CHIP DIR = 0, W/R = 0, RD = 0, CE = 0      C/D, FS, RV = 0
  13.     *((volatile unsigned int*)0x400E1230) = (0x1 << 12);
  14.  
  15.     //OUTPUT ENABLE C12-C19                check with PIO_OSR 0x400E0018
  16.     *((volatile unsigned int*)0x400E1210) = (0xFF << 12);
  17.  
  18.    //PORT ENABLE D0 (DISPLAY RESET)
  19.    *((volatile unsigned int*)0x400E1400) = (1 << 0);
  20.  
  21.     //OUTPUT ENABLE OE CONTROL (D0)                             check with PIO_OSR 0x400E1218, 0=pure input
  22.     *((volatile unsigned int*)0x400E1410) = (1 << 0);
  23.  
  24.     //CLEAR DISPLAY RESET
  25.     *((volatile unsigned int*)0x400E1434) = (1 << 0);
  26.  
  27.     util_Delay(1000);
  28.     //_delay_Systick(8000, 5);
  29.  
  30.     //SET DISPLAY RESET                        check with OSDR
  31.     *((volatile unsigned int*)0x400E1430) = (1 << 0);
  32.  
  33.     //INITIALISE GRAPHIC & TEXT
  34.     _display_WriteData(0x00);    
  35.     _display_WriteData(0x00);
  36.     _display_WriteCommand(0x40); //Set text home adress
  37.  
  38.     _display_WriteData(0x00);    
  39.     _display_WriteData(0x40);
  40.     _display_WriteCommand(0x42); //Set graphic home adress
  41.  
  42.     _display_WriteData(0x1E);    
  43.     _display_WriteData(0x00);
  44.     _display_WriteCommand(0x41); //Set text area (changed from 41)
  45.  
  46.     _display_WriteData(0x1E);    
  47.     _display_WriteData(0x00);
  48.     _display_WriteCommand(0x43); //Set graphic area
  49.  
  50.     _display_WriteCommand(0x80); //Text mode
  51.     _display_WriteCommand(0x94); //Text on, graphic off
  52. }
  53.  
  54.  
  55. unsigned char _display_ReadStatus(void){
  56.             //READS STATUS WORD FROM DISPLAY CHIP VIA DATABUS ON PIO_C
  57.             //STATUS WORD 0x3 MEANS CHIP IS READY
  58.  
  59.     unsigned char readbyte;
  60.    
  61.     //SET DATABUS C2-C9 AS INPUT
  62.     *((volatile unsigned int*)0x400E1214) = (0xFF << 2);
  63.  
  64.     //SET DIR AS INPUT (1)    
  65.     *((volatile unsigned int*)0x400E1230) = (1 << 13);
  66.  
  67.     //CLEAR 74CHIP OUTPUT ENABLE  (0 = ENABLE)
  68.     *((volatile unsigned int*)0x400E1234) = (1 << 12);
  69.  
  70.     //SET C/D    (C/D=1 & RD=0 > STATUS READ)
  71.     *((volatile unsigned int*)0x400E1230) = (1 << 17);
  72.  
  73.     //CLEAR DISPLAY CHIP SELECT  (0 = ACTIVE)
  74.     *((volatile unsigned int*)0x400E1234) = (1 << 16);
  75.  
  76.     //CLEAR DISPLAY RD
  77.     *((volatile unsigned int*)0x400E1234) = (1 << 15);
  78.  
  79.     util_Delay(20);
  80.  
  81.     //READ DATABUS C2-C9, save in Temp char MASK??
  82.  
  83.     readbyte = (((unsigned char) *((unsigned int*)0x400E123C) & (0xFF << 2)) >> 2);
  84.  
  85.     //SET CHIP SELECT DISPLAY
  86.     *((volatile unsigned int*)0x400E1230) = (1 << 16);
  87.  
  88.     //SET READ DISPLAY
  89.     *((volatile unsigned int*)0x400E1230) = (1 << 15);
  90.  
  91.     //DISABLE CHIP (OE = 1)
  92.     *((volatile unsigned int*)0x400E1230) = (1 << 12);
  93.  
  94.     //DIR AS OUTPUT, DIR = 0
  95.     *((volatile unsigned int*)0x400E1234) = (1 << 13);
  96.  
  97.     return readbyte;
  98. }
  99.  
  100. void _display_WriteData(unsigned char data){
  101.             //WAITS FOR CONTROLLER READY AND THEN
  102.             //WRITES DATA CHAR VIA DATABUS ON PIO_C
  103.  
  104.     while((_display_ReadStatus() & (3 << 0)) != (3 << 0)){}
  105.  
  106.  
  107.     //CLEAR DATABUS C2-C9
  108.     *((volatile unsigned int*)0x400E1234) = (0xFF << 2);
  109.  
  110.     //SET DATA TO C2-C9
  111.     *((volatile unsigned int*)0x400E1230) = (data << 2);
  112.  
  113.     //SET DIR TO OUTPUT IN CHIP (0)
  114.     *((volatile unsigned int*)0x400E1234) = (1 << 13);
  115.    
  116.     //CHIP74 OE OUTPUT (0)
  117.     *((volatile unsigned int*)0x400E1234) = (1 << 12);
  118.  
  119.     //ENABLE OUTPUT C2-C9
  120.     *((volatile unsigned int*)0x400E1210) = (0xFF << 2);
  121.  
  122.     //CLEAR C/D SIGNAL HI (0 = Data)
  123.     *((volatile unsigned int*)0x400E1234) = (1 << 17);
  124.  
  125.     //CLEAR CHIP SELECT DISPLAY
  126.     *((volatile unsigned int*)0x400E1234) = (1 << 16);
  127.  
  128.     //CLEAR WRITE DISPLAY (WRITE = 0)
  129.     *((volatile unsigned int*)0x400E1234) = (1 << 14);    
  130.  
  131.     util_Delay(20);
  132.  
  133.     //SET CHIP ENABLE DISPLAY
  134.     *((volatile unsigned int*)0x400E1230) = (1 << 16);
  135.  
  136.     //SET WRITE DISPLAY
  137.      *((volatile unsigned int*)0x400E1230) = (1 << 14);
  138.  
  139.     //DISABLE, OE=1
  140.     *((volatile unsigned int*)0x400E1230) = (1 << 12);
  141.  
  142.     //DIR AS OUTPUT, DIR = 0
  143.     *((volatile unsigned int*)0x400E1234) = (1 << 13);
  144.  
  145.     //DATABUS AS INPUT
  146.     *((volatile unsigned int*)0x400E1214) = (0xFF << 2);
  147. }
  148.  
  149. void _display_WriteCommand(unsigned char command){
  150.             //WAITS FOR CONTROLLER READY AND THEN
  151.             //WRITES COMMAND DATA VIA DATABUS ON PIO_C
  152.    
  153.     while((_display_ReadStatus() & (3 << 0)) != (3 << 0)){}
  154.  
  155.     //CLEAR DATABUS C2-C9
  156.     *((volatile unsigned int*)0x400E1234) = (0xFF << 2);
  157.  
  158.     //SET DATA TO DATABUS C2-C9
  159.     *((volatile unsigned int*)0x400E1230) = (command << 2);
  160.  
  161.     //SET DIR AS OUTPUT IN CHIP (0)
  162.     *((volatile unsigned int*)0x400E1234) = (1 << 13);
  163.  
  164.     //OE OUTPUT (1)
  165.     *((volatile unsigned int*)0x400E1234) = (1 << 12);
  166.  
  167.     //ENABLE OUTPUT C2-C9
  168.     *((volatile unsigned int*)0x400E1210) = (0xFF << 2);
  169.  
  170.     //SET C/D SIGNAL HI (1 = Command)
  171.     *((volatile unsigned int*)0x400E1230) = (1 << 17);
  172.  
  173.     //CLEAR CHIP SELECT DISPLAY
  174.     *((volatile unsigned int*)0x400E1234) = (1 << 16);
  175.  
  176.     //CLEAR WRITE DISPLAY (0=WRITE)
  177.     *((volatile unsigned int*)0x400E1234) = (1 << 14);    
  178.  
  179.     util_Delay(20);
  180.  
  181.     //SET CHIP ENABLE DISPLAY
  182.     *((volatile unsigned int*)0x400E1230) = (1 << 16);
  183.  
  184.     //SET WRITE DISPLAY
  185.     *((volatile unsigned int*)0x400E1230) = (1 << 14);
  186.  
  187.     //DISABLE CHIP OE=1)
  188.     *((volatile unsigned int*)0x400E1230) = (1 << 12);
  189.  
  190.     //DIR AS OUTPUT, DIR = 0
  191.     *((volatile unsigned int*)0x400E1234) = (1 << 13);
  192.  
  193.     //DATABUS AS INPUT
  194.     *((volatile unsigned int*)0x400E1214) = (0xFF << 2);
  195. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top