migration from 16F876a to 18F25k22


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22

    Great Robert, thanks a bunch! I'll follow through on these and may have a question or two after I have spent some time playing with them.
    Wayne

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22


  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22

    Hi,
    Regarding the two "EBAY-units" linked to in post #9. It looks to me as if these units have the display driver onboard but NOT the display controller (like the SED1330, RA6963 etc) OR any RAM. This means you're going to have to build the complete frame in memory (internal or external to the PIC) and then continously keep refreshing the display with that data (320*240/8=9600bytes).

    If I'm correct on that point it'll be a real challenge to drive either of these with a PIC.

    What you're looking for is a unit with display driver AND controller AND RAM. Alternatively something like this module to compliment the actual LCD-module.

    /Henrik.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Regarding the two "EBAY-units"...
    If I'm correct on that point it'll be a real challenge...
    Yes, those will be hard to operate, that's why I gave more info on the SED model and said it's important to find a parallel model.

    If there are clock or latch pins, stay away from those LCDs. That's why they are cheap, hobbyists don't buy them.

    Robert

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22

    I just found this lying around in My Documents of an old PC:

    Code:
    '--------------------------------------------------------------------'
    ' Author:  Demon                                              '
    ' Date:    April 7th, 2006                                           '                                                                   '
    ' Language:   PIC Basic Pro v2.46                                    '
    ' MPU:        PIC 16F877 20/P from MicroChip                         '
    ' IDE:        MicroCode Studio Plus from Mecanique v2.2.1.1          '
    ' Programmer: MeLabs Serial Programmer v3.12 (firmware v3.4)         '
    ' LCD:        LCM3202401 from QingYun-IT                             '
    '                                                                    '
    ' All rights reserved.                                               '
    '                                                                    '
    ' Use of parts of code is permitted as long as credit is given       '
    ' to the author.  Code may or may not be Year 3000 proof.  Use       '
    ' at your own risk.                                                  '
    '--------------------------------------------------------------------'
    
    'define  LOADER_USED 1
    clear
    ADCON1	= 7
    
    ASM
    @ DEVICE PIC16F877, HS_OSC, WDT_OFF, PWRT_ON, BOD_ON, LVP_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF, PROTECT_OFF
    ENDASM
    
    DEFINE OSC 20
    
    pinData     var PORTD          
    pinWR       var PORTB.0       
    pinRD       var PORTB.1         
    pinCS       var PORTB.2      
    pinA0       var PORTB.4 
    pinRST      var PORTB.5        
    pinLED      VAR PORTB.3
    pinSCL      VAR PORTC.3
    pinSDA      VAR PORTC.4
    
            TRISD   = 0
            TRISB.0 = 0
            TRISB.1 = 0
            TRISB.2 = 0
            TRISB.4 = 0
            TRISB.5 = 0
            TRISB.3 = 0
    
    conSet		        con	$40
    conScroll	        con	$44
    conCursorForm	    con	$5d
    conCursorAddress	con	$46
    conCursorRight	    con	$4c
    conOverlay	        con	$5b
    conWrite	        con	$42
    conDisplayON	    con	$59
    conDisplayOFF	    con	$58
    conCharPerLine		con	$28 	' 40  characters / line
    
    varCommand	Var	BYTE
    varCursor   var BYTE
    varByte		var	BYTE
    varLoop1	var	BYTE
    varLoop2	var	BYTE
    varAddress	var	WORD
    
        	pinRD  = 1
        	pinWR  = 1
            pinCS  = 0
            pinRST = 0
            pause 1
            pinRST = 1
            pause 100
    
            goto main
    
    ' --------------------------- Subroutines --------------------------
    
    'INCLUDE "SED1335 subroutines.pbp"
    SendData:
    	pinA0	= 0
    	pinData = varByte
    	pinWR	= 0
    '	@ nop
    	pinWR	= 1
    return
    
    SendCommand:
    	pinA0	= 1
    	pinData = varCommand
    	pinWR	= 0
    '	@ nop
    	pinWR	= 1
    return
    
    ClearGraphic:
    	varCommand = conCursorAddress
    	gosub SendCommand
    	varByte = $00
    	gosub SendData
    	varByte = $10
    	gosub SendData
    
    	varCommand = conCursorRight
    	gosub SendCommand
    
    	varCommand = conWrite
    	gosub SendCommand
        varByte = %00000000            ' 1 byte = 8 bits = 8 pixels wide
    	for varLoop1 = 1 to 240        ' 240 pixels high
    	   for varLoop2 = 1 to 40      ' 40 bytes = 320 bits = 320 pixels wide
    		gosub SendData
    	   next varLoop2
    	next varLoop1
    return
    
    ClearText:
    	varCommand = conCursorAddress
    	gosub SendCommand
    	varByte = $00
    	gosub SendData
    	varByte = $00
    	gosub SendData
    
    	varCommand = conCursorRight
    	gosub SendCommand
    
    	varCommand = conWrite
    	gosub SendCommand
        varByte = " "
    	for varLoop1 = 1 to 30
    	   for varLoop2 = 1 to 40
    	       gosub SendData
    	   next varLoop2
    	next varLoop1
    return
    
    InitDisplay:
    	varCommand = conSet
    	gosub SendCommand
    	for varLoop1 = 0 to 7
     		lookup varLoop1,[$32,$87,$07,$27,$2B,$EF,$28,$00],varByte
    		gosub SendData
    	next varLoop1
    
    	varCommand = conScroll
    	gosub SendCommand
    	for varLoop1 = 0 to 5
     		lookup varLoop1,[$00,$00,$EF,$00,$10,$EF],varByte
    		gosub SendData
    	next varLoop1
    
    	varCommand = conOverlay
    	gosub SendCommand
    	varByte = %00000001
    	gosub SendData
    
    	varCommand =conDisplayOFF
    	gosub SendCommand
    	varByte = %00000000
    	gosub SendData
    	
    	gosub ClearText
    	gosub ClearGraphic
    
    	varCommand = conDisplayON
    	gosub SendCommand
        varByte = %00010100
        gosub SendData
    
    	varCommand = conCursorAddress
    	gosub SendCommand
    	varByte = $0
    	gosub SendData
    	varByte = $0
    	gosub SendData
    
    	varCommand =conCursorForm
    	gosub SendCommand
    	varByte = $04
    	gosub SendData
    	varByte = $86
    	gosub SendData
    return
    
    SetAddress:
    	varCommand = conCursorAddress
    	gosub SendCommand
    	varByte = varAddress.BYTE0
    	gosub SendData
    	varByte = varAddress.BYTE1
    	gosub SendData
    
    	varCommand = varCursor
    	gosub SendCommand
    
       	varCommand = conWrite
       	gosub SendCommand
    return
    
    ' --------------------------- Main program --------------------------
    
    Main:
    	gosub InitDisplay
    
        pinLED = 1
    
      	varAddress = 0
       	varCursor  = conCursorRight
       	gosub SetAddress	
    
       	for varLoop1 = 0 to 39
        	lookup varLoop1,[".. QINGYUN IT LCM-3202401 GRAPHIC LCD .."],varByte
       		gosub SendData
        NEXT varLoop1
    
       	varAddress = 29 * conCharPerLine
       	varCursor  = conCursorRight
       	gosub SetAddress	
    
       	for varLoop1 = 0 to 39
        	lookup varLoop1,["Demon was here!                         "],varByte
       		gosub SendData
        NEXT varLoop1
    end
    It's old and not cleaned up, but at least it's a start.

    Robert


    EDIT: LOL Look what I found while looking at my attachments:
    http://www.picbasic.co.uk/forum/showthread.php?t=3811
    Last edited by Demon; - 4th October 2016 at 16:28.

  6. #6
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: migration from 16F876a to 18F25k22

    Robert, thanks for the code. It does look like a good starting point, clean, simple. I have a GLCD on the way from EgoChina which uses a S1D13700 controller. ($75) My first purchase of a GLCD, which means it looks like it has everything needed on the board. (I hope) I’m just figuring out the details of how to set it up. I’ll start with a code format following your example.
    Thanks again,
    Wayne

  7. #7
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Is Vo always negitive?

    Do you know that uneasy felling in the pit of your stomach when you’re about to put voltage on an expensive piece of equipment and you’re NOT 100% sure "this is the right way to do it"? You realize that you may be moments away from filling the workshop with a cloud of green (the color of money) smoke! You also know that if you don’t do this you will never know if it works because, it’s not going to start by itself… OR, you can first consult the guys at MEL PICBASIC Forum and perhaps someone may be able to guide you through the mine fields. If you still go up in smoke you may be able to find one sympathetic soul somewhere on the face of the glob that will share your pain, NOT likely, BUT perhaps someone else will learn some small lesson from the experience of your smoldering carcass…

    My new GLCD from china, of course has very little documentation. It is not clear how to handle the LED’s or Vo. Vee is at -23V. The data sheet says:
    Vdd-Vss 4.75-5.25V
    Vdd-Vo 4.5V to 30V
    I am (almost) sure a 10K pot between Vee (-23V) and Vo should make it work. I am not sure about the LED’s. In fact I can’t find out the difference in function between the LEDA and LEDK or why the one page data sheet shows a resistor between a back light block and LEDA while there is no resistor for LEDK. ANY INPUT WILL BE APPRECIATED !

    Using an 18F45K22 at 16Mhz internal, JHD639 320240 GLCD w/D1370002A1 controller , my code is almost done. I have followed Robert’s SED1335 example, thanks Robert, as the coding is very close for each controller though the 137000 seems to be a bit more involved.

    Wayne

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts