Help with S1D13700 Display and 18F4520

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
2brain
Posts: 18
Joined: Fri Jan 22, 2010 1:04 pm
Location: Hong Kong

Help with S1D13700 Display and 18F4520

Post by 2brain » Fri Jan 29, 2010 3:51 pm

Pixel problem 18F4520 & S1D13700 LCD Driver

My problem is that while I can see the basis of letters and lines the horizontal spacing seems to be out of whack. I get proper (good) vertical stacked pixels forming the edge of boxes but the gap between the edges is just evenly spaced single pixels, which look like they are 7 pixels apart or perhaps 8. Letters which involve diagonal lines are spotty with pixels missing, lines using the lines command also are just a series of widely spaced out (I think I could be going that way too) dots. The fact the pixels are in the right place leads to think data lines are ok and because it actually displays what I expect then the control lines are ok. Both PIC and display are running from 5V.

My thoughts are that the X spacing is using the byte character spacing but I’ve been going around in circles. I’ve checked the S1D13700 initialization codes against the data sheet and can’t see any problem, I changed the display and the PIC, and although the PIC is mounted on my own prototype PCB I have buzzed the connections out through to the S1D13700 chip on the display. The code I’m using now is basically taken from several forum responses, graphics program and PIC configuration.

Any ideas welcome! Any Help most welcome!
The code has several alternative attempts commented out, e.g. I was using an external crystal but the 8MHz internal solved a problem where everything was 'shadowed' but I did try 32MHz via PLL but had the same shadowing problem just not so bad.

Code: Select all

Device=18F4520
//Clock=25                  //Crystal on pins 13 &14
Clock = 25                   //temp try internal osc

Config  osc = hs,//intio67,   //Internal Oscillator with I/O on RA6 and RA7 or osc=HS
       DEBUG=OFF,        //Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
       mclre = OFF,      //RE3 input pin enabled; MCLR disabled
       FCMEN=OFF,        //Fail-Safe Clock Monitor disabled
       IESO=OFF,         //Oscillator Switchover mode disabled
       PWRT=ON,          //Power-up Timer disabled
       BOREN=OFF,        //Brown-out Reset disabled in hardware and software
       BORV=0,           //Brown-out Reset Voltage Maximum setting
       WDT=OFF,          //WatchDog Timer disabled
       WDTPS = 128,      // 1:1 Watchdog Timer Postscale
       LPT1OSC=OFF,      //Timer1 configured for high power operation
       PBADEN=OFF,       //POR set portb to digital I/O
       STVREN=OFF,       //Stack full/underflow will not cause Reset
       LVP=OFF,          //don't use low voltage programming 
       XINST=OFF,        //don't use extended instruction set 
       CCP2MX=PORTC      //use CCP2 on PORTc   
        
        
 
    
 //====user settings to override default module options ====
#option GLCD_MODEL = S1D13700      //Controller mounted on display
#option GLCD_MODEL = 6800          //hardware default M6800 Indirect CNF<3:2>
#option GLCD_DATA = PORTB          // Data port - only 8 bit port
#option GLCD_RES = PORTC.7         // reset pin   
#option GLCD_EN = PORTD.5          // EN pin - 6800 mode
#option GLCD_RD = PORTD.5          // RD pin - 8080 mode
#option GLCD_RW = PORTD.6          // RW pin - 6800 mode
#option GLCD_WR = PORTD.6          // WR pin - 8080 mode
#option GLCD_A0 = PORTD.7          // A0 pin
#option GLCD_CS = PORTD.4          // chip select 
#option GLCD_TCR = $2C             // TC/R setting to fix flicker problem on display override system  instruction ($48)
#option GLCD_ASPECT_RATIO = 100    // aspect ratio, smaller number will squeeze y For GLCD circles And Boxes
#option GLCD_INIT_DELAY = 100      // initialisation delay (ms)
   

Include "s1d13700.bas"
Include "GLCD.bas"
Include "Graphics.bas"  
Include "Bitmaps.bas"
Include "Arial.bas" 
Include "Convert.bas"
//Include "SansSerif.bas"
//Include "TouchScreen.BAS"
//Include "SPI.bas" 
//Include "Utils.bas"
//Include "String.bas"
//Include "SDFileSystem.bas"

 
 Dim cindex,yindex,i As Byte
 
       //================Main Program ===================
 
   //OSCCON.6 = 1              // Set Internal OSC to 8Mhz 
   //OSCCON.5 = 1              //        " 
   //OSCCON.4 = 1             //        " 
   OSCTUNE.6 = 0           // Turn off/on PLL 
             



// temp - LED 5 flashes before writting to screen

High(PORTB.4)

For cindex=1 To 5      
      Toggle(PORTB.4)      
      DelayMS(250)
      Toggle(PORTB.4)     
      DelayMS(250)
Next    

//To write black text (Pen.Color = 1) 
//To write white background (Brush.Color = 0)
Cls(1)
Pen.Color = 1
Brush.Color =0
Pen.Mode = 0     // pen modes, pmCopy = 0, pmMerge = 1, pmXOR = 2,
Brush.Style = 0   //1=bsClear  0=bsSolid
SetFont(Arial)

//SetFont(SansSerif)
SetPixel(20, 20)
SetPixel(20, 21)
SetPixel(20, 22)
SetPixel(20, 23)
SetPixel(20, 24)

MoveTo(28,28)
LineTo(210,28)
  
WriteAt(33,100,"A1--------A2........A3--------A4........A5////////A6") 
WriteStr(47,60,"A1B2C3")
  
Square(50,150,60)

Rectangle(120, 100, 250, 180)

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Fri Jan 29, 2010 9:23 pm

I haven't looked at the datasheet for the PIC, but are your ports also analogue ports and do you need to set them to digital?

And welcome to the forum!

2brain
Posts: 18
Joined: Fri Jan 22, 2010 1:04 pm
Location: Hong Kong

Post by 2brain » Sat Jan 30, 2010 12:18 pm

Many thanks for the welcome Steve.
I did have ‘setalldigital’ previously but saw it was also in one of the modules, S1D13700 I think but I did try it again, no difference, I also switched off some other registers but no change.

As far as I could see the 4520 is just a smaller memory version of the 4620. Port B while being used for analogue data does also have a 'fuse config' setting to set it to Digital I/O after reseet.
In general was there any previous problem using clocks over 10MHz or using graphic’s images, I can’t seem to include ‘OK or Cancel’ push buttons, they come out as Korean characters (Kanji). With the clock over 8MHz I get 2 images offset by about 16 pixels.

I have also found that there have been several versions of the Functional Specification, I’ve now got version 4.03 to see what may have changed. I have also just noticed that the chip is actual labelled D137000 1A1, I'm not sure if that makes any difference.

If I wanted to include photos is there any free site to upload to, to get a url?

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Sat Jan 30, 2010 12:23 pm


2brain
Posts: 18
Joined: Fri Jan 22, 2010 1:04 pm
Location: Hong Kong

Post by 2brain » Sat Jan 30, 2010 2:42 pm

Some pictures of the problem


Image

Image

Image
The boxes created by square and rectangle, you can just about see the lettering, A1-------A2 etc.

Image
With clock >8MHz

Post Reply