![]() |
|
|||||||
| Proton Plus Compiler v3 Coding problems and general discussion related to the Development Suite |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Hi,
I got a samsung display 2 days ago and it only displayed garbage until today when I set the internal oscillator to 4 megahertz. here is a link to the info about the GLCD: https://www.crystalfontz.com/product...864ACFHTA.html I would like to set the operating frequency to 8 mhz at least, this PIC can operate at 32mhz using its internal oscillator and PLL. I would like that very much. But when I do it at anything else than 4 mhz, I just get the garbage. I have tried using 3 different PICs models and this is the code from the latest pic I am trying. I just received this PIC today and am not sure that it is configured correctly - but it does display right at 4 mhz. I have added long delays and tweaked it alot in different ways but still no go. ![]() I could sure use some suggestions. Device 18F4620 Config_Start OSC = intio7 ; INTRC-OSC2 as Clock Out, OSC1 as RA7 FCMEN = OFF ; Disabled IESO = OFF ; Disabled PWRT = OFF ; Disabled BOREN = Off ; SBOREN BORV = 2 ; WDT = OFF ; Disabled WDTPS = 1 ; 1:1 LPT1OSC = OFF ; Disabled PBADEN = OFF ; PORTB<4:0> digital on Reset CCP2MX = PORTC ; Multiplexed with RC1 STVREN = Off ; LVP = OFF ; Disabled XINST = OFF ; Disabled Debug = OFF ; Disabled CP0 = OFF ; Disabled CP1 = OFF ; Disabled CP2 = OFF ; Disabled CP3 = OFF ; Disabled CPB = OFF ; Disabled CPD = OFF ; Disabled WRT0 = OFF ; Disabled WRT1 = OFF ; Disabled WRT2 = OFF ; Disabled WRT3 = OFF ; Disabled WRTB = OFF ; Disabled WRTC = OFF ; Disabled WRTD = OFF ; Disabled EBTR0 = OFF ; Disabled EBTR1 = OFF ; Disabled EBTR2 = OFF ; Disabled EBTR3 = OFF ; Disabled EBTRB = OFF ; Disabled Config_End Reminders true All_Digital = true Xtal 8 OSCCON.6=1 OSCCON.5=1 OSCCON.4=1 'OSCTUNE.6=1 ' enable PLL 32mhz! 'Declare PLL_Req = On LCD_Type = graphic LCD_DTPort PORTB LCD_RWPin PORTC.0 LCD_CS1Pin PORTC.1 LCD_CS2Pin PORTC.2 LCD_ENPin PORTC.3 LCD_RSPin = PORTA.3 LCD_RSTPin = PORTD.1 GLCD_CS_Invert = 1 Declare GLCD_STROBE_DELAY 10 Declare GLCD_READ_DELAY 2 'DECLARE LCD_DATAUS 255 Internal_Font = On Font_Addr = 0 Stack_Size = 4 Symbol BLUE PORTA.0 Symbol RED PORTA.1 Symbol GREEN PORTA.2 Symbol LED PORTA.4 Symbol buzzer PORTA.5 Dim N As Byte Dim XPOS As Byte High buzzer While OSCCON.2 = 0 'Wait for OSC to stabalize DelayMS 1 Wend Low buzzer For N = 0 To 5 High LED DelayMS 500 Low LED DelayMS 500 Next 'has rgb led backlight Low RED Low BLUE Low GREEN High LED DelayMS 4000 MAIN: Cls Low LED DelayMS 1000 Print At 0,0,"Wohoo! It works now!!" Print At 1,0," This Is Cool!" High LED DelayMS 2000 Cls DelayMS 1000 Low LED For XPOS = 0 To 63 Print At 5,2,Dec3 XPOS LCDWrite 4 , XPOS, [%11111111] DelayMS 100 LCDWrite 4 , 127-XPOS, [%11111111] DelayMS 100 Next DelayMS 1000 For XPOS = 0 To 63 Print At 5,2,Dec3 XPOS LCDWrite 5 , XPOS, [%11111111] LCDWrite 5 , 127-XPOS, [%11111111] DelayMS 100 Next Circle 1,10,10,5 Circle 1,30,30,10 Low LED DelayMS 1000 GoTo MAIN Include "FONT.INC" ---- Thank you Jon Last edited by brown; 28th January 2010 at 01:15. Reason: clarifying |
|
|
|
|
|
#2 |
|
Licensed User
![]() |
John
have you tried this LCD_Type = samsung instead of LCD_Type = graphic |
|
|
|
|
|
#3 |
|
Licensed User
![]() Join Date: Feb 2004
Location: Aberdeen Scotland
Posts: 1,220
![]() |
Try also adjusting these declares
DECLARE GLCD_STROBE_DELAY 0 to 65535 us (microseconds). Create a delay of n microseconds between strobing the EN line of the graphic LCD. This can help noisy, or badly decoupled circuits overcome random bits appearing on the LCD. The default if the DECLARE is not used in the BASIC program is a delay of 0. DECLARE LCD_COMMANDUS 1 to 65535 microseconds (us). Time to wait (in microseconds) between commands sent to the LCD. If the DECLARE is not used in the program, then the default delay is 2000us (2ms). DECLARE LCD_DATAUS 1 to 255 microseconds (us). Time to wait (in microseconds) between data sent to the LCD. If the DECLARE is not used in the program, then the default delay is 50us. |
|
|
|
|
|
#4 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Hi,
I changed to LCD_Type = samsung but I think proton regards LCD_Type 1, graphic and samsung as the same. I I tried increasing the delays and finally maxed them all out: Declare GLCD_STROBE_DELAY 65535 Declare LCD_DataUs 255 Declare GLCD_READ_DELAY 255 Declare LCD_CommandUs 65535 but still just garbage on the screen . maybe if I give it 110volts AC it will work better ![]() Can you think of anything else that I might try? Thanks Jon |
|
|
|
|
|
#5 |
|
Licensed User
![]() Join Date: Oct 2005
Location: Crime riddled ZA
Posts: 7,495
![]() |
One thing you could try is to define the clock for 4MHz where you write to the display. The pic will run at 8MHz except when writing to the display.
It should not slow the pic down more than when you slow it down in declares... You just need to change the clock register... can't remember what it's called. Last edited by fanie; 28th January 2010 at 23:46. |
|
|
|
|
|
#6 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Hi Fanie, is it the OSCCON register?
like: for 4 MHZ set the- OSCCON.6=1 OSCCON.5=1 OSCCON.4=0 that should set it back to 4MHZ and if I am using the PLL then - OSCTUNE.6=0 to disable it I will test it to see something like this maybe?: 'at 32mhz Main: gosub 4mhz gosub print gosub 32mhz delayms 1000 goto main 4mhz: 'Drop to 4mhz XTAL = 4 OSCCON.6=1 OSCCON.5=1 OSCCON.4=0 OSCTUNE.6=0 PLL_Req = OFF return 32mhz: 'return to 32mhz XTAL = 8 OSCCON.6=1 OSCCON.5=1 OSCCON.4=1 OSCTUNE.6=1 PLL_Req = ON return Print: cls print at 0,0,"Hello" return Is that what you mean? I'm not too sure proton would respect that but I will try. Thanks Jon |
|
|
|
|
|
#7 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
oh doh,
I can't re-declare xtal or pll_reg whenever I feel like it. So I removed those declares and only used the osccon and osctune regs, Yes, it is working! I was worried that if I changed the PIC clock speed without re-declaring the XTAL & PLL_REG that Proton's timing would be all messed up. I suppose it is but only when I am drawing to the screen. How could I make a function so I could do: Slow_CPU cls print at 0,0,"SLOW and WORKING.." Fast_CPU Thanks Fanie, that was clever! Jon |
|
|
|
|
|
#8 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Ok, after playing around with this for awhile, I think that having to slow the pic down to 4mhz every time I want to write to the GLCD is not so great. I am very disappointed with it. Maybe I didn't understand its datasheet and should have known that it is junk.
I think I should just send it back to crystalfontz and exchange it for something decent if they will let me. Before I purchased it, I asked the forum if it would work with Proton, instead with lesson learned I want to ask what GLCD should I get? Which one do you like to use with Proton? Which one can work well with a high PIC clock speed like 32mhz? Thanks, Jon |
|
|
|
|
|
#9 |
|
Licensed User
![]() Join Date: Oct 2003
Location: New Zealand
Posts: 65
![]() |
From memory I had problems with that display and set GLCD_CS_Invert = 0
|
|
|
|
|
|
#10 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
When I try that, it just swaps the left and right halves of the screen.
Not too long ago, I came across a forum message where somebody declared their own function or overrode a predefined function. I have searched the forums but cant find it. maybe it was on a totally different site, maybe if I could do that, I could just write a wrapper to do the temporary CPU speed adjustment and then it wouldn't be so bad. I could make a function called "printt" for changing the CPU speed to slow, then printing and then setting the speed back. is that possible? |
|
|
|
|
|
#11 | |
|
Licensed User
![]() Join Date: May 2008
Location: Sydney, Australia
Posts: 1,453
![]() |
Quote:
http://www.picbasic.org/forum/showthread.php?t=12019 http://www.picbasic.org/forum/showthread.php?t=11653 DaveS gave me this code that could be adapted to your purposes: Code:
#Disable GLCD_Cls
#Disable GLCD_Cursor
#Disable Print
Asm
Cls
GLCD@CLS
GoTo GLCDCls ;Point to your routine
Cursor
GLCD@CUR
WREG_BYTE X_CursorPos ;variable
movff GEN,Y_CursorPos ;variable
GoTo GLCD_GoToYX ;Point to your routine
Print ;WORKS see quirk in notes
WREG_BYTE GLCD#CHAR ;GLCD#CHAR = Char number variable
GoTo GLCDChar ;Point to your routine
EndAsm
|
|
|
|
|
|
|
#12 | |
|
Licensed User
![]() Join Date: Aug 2005
Location: Kent.
Posts: 1,477
![]() |
Hi Brown, (do you have a real name?)
Quote:
I run these "type" of displays at 40mhz and do not do anything special. The only thing I note is you appear to be using portB for the GLCD, I always use portD and believe I use the 4620 also. If you can, try the GLCD on portD, it may be that there is a peripheral on portB that you have not turned off ot even portC which does not appear to affect it at lower speeds. I would try to use the outputs exactly as per the help file and possibly the example just to prove it. Regards, Bob Last edited by RGV250; 29th January 2010 at 09:00. |
|
|
|
|
|
|
#13 |
|
Licensed User
![]() Join Date: Oct 2005
Location: Crime riddled ZA
Posts: 7,495
![]() |
By changing the value in the OSCCON register you can on the fly chop and change the pic's frequency.
Sorry, I haven't read all the posts I'm a bit pressed for time here... |
|
|
|
|
|
#14 |
|
Licensed User
![]() Join Date: Feb 2004
Location: Aberdeen Scotland
Posts: 1,220
![]() |
I doubt that the problem is with the display.
Most displays are able to tell the controller when it has finished processing the last command. Proton does not use this method. Instead the default LCD write times are calculated to be longer than normally required. The declares allow us to adjust the timing to cope with slower displays. As far as I know the timing is done purely in software controlled loops the timing of which is calculated from the oscillator speed that we declare at the top of our code, therefore if the display operates at 4MHz it should operate at 8 or 20MHz. So the conclusion has to be that the PIC is not operating higher than the declared frequency for some reason. A simple test would be to stick on an LED and toggle it at 1 or 5 second intervals in a loop and see if the timing is about right. Even better would be to configure the PIC to output the oscillator and measure the clock speed. Last edited by See_Mos; 29th January 2010 at 12:55. |
|
|
|
|
|
#15 |
|
Licensed User
![]() Join Date: Feb 2004
Location: Aberdeen Scotland
Posts: 1,220
![]() |
oooops, that should have been:-
So the conclusion has to be that the PIC is operating higher than the declared frequency for some reason. |
|
|
|
|
|
#16 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Hi Bob, my real name is Jon Brown
I should fill in my user profile. Hey your location says Kent - is that Kent, Washington? if so you are pretty close to me, here in Sultan, WA. I will move the data lines to port D and try again, I chose port B because it is all on the same side of the PIC and in 0-7 order. If moving the data lines to port D doesn't make a difference, then I will move the control lines to port B and see if I get an improvement. See_Mos: I have done the LED test and it seems to be clocked fine, but I will use a watch and run it for 10 seconds or so to be sure. Thanks for your time Jon |
|
|
|
|
|
#17 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Well, the results are the same,
I switched data to portd and same results, then put the control lines to portB and same results. Then used a non-beta compiler just in case, but same results. I added in code to blink a LED for 20 seconds and timed it and the timing is perfect. I don't have a O-scope available. So I am playing with Macros thinking that if I made a macro like this: Gprint Macro Byte_X,Byte_Y,String_Text OSCCON.6=1 ' down to 4mhz OSCCON.5=1 OSCCON.4=0 OSCTUNE.6=0 Print Byte_X,Byte_Y,String_Text OSCCON.6=1 'up to 32mhz OSCCON.5=1 OSCCON.4=1 OSCTUNE.6=1 Endm then I could call: gprint 0,0,"TADA!" but there is not much documentation on macros, can they handle strings? Regards, Jon |
|
|
|
|
|
#18 |
|
Licensed User
![]() Join Date: Aug 2005
Location: Kent.
Posts: 1,477
![]() |
Hi Jon,
Kent, little old England (across the pond) I would try to use one of the examples in the sample folder and the circuit exactly as it is in the help file. You could also look at the VSM to test it. I have the 18 series VSM so I will try your code out tonight when I get home just to prove that. Regards, Bob |
|
|
|
|
|
#19 |
|
Licensed User
![]() Join Date: Aug 2005
Location: Kent.
Posts: 1,477
![]() |
Hi,
This works in a simulation, not pretty but i do not have the time to tidy it up and you need to uncomment some of it anyway. I have commented a lot out just to speed up the sim, some of it marked with **************. If you have any queries let me know. I also changed the osc for me. Regards, Bob Code:
Device 18F4620 Config_Start OSC = HS ; INTRC-OSC2 as Clock Out, OSC1 as RA7 ***************** FCMEN = OFF ; Disabled IESO = OFF ; Disabled PWRT = OFF ; Disabled BOREN = Off ; SBOREN BORV = 2 ; WDT = OFF ; Disabled WDTPS = 1 ; 1:1 LPT1OSC = OFF ; Disabled PBADEN = OFF ; PORTB<4:0> digital on Reset CCP2MX = PORTC ; Multiplexed with RC1 STVREN = Off ; LVP = OFF ; Disabled XINST = OFF ; Disabled Debug = OFF ; Disabled CP0 = OFF ; Disabled CP1 = OFF ; Disabled CP2 = OFF ; Disabled CP3 = OFF ; Disabled CPB = OFF ; Disabled CPD = OFF ; Disabled WRT0 = OFF ; Disabled WRT1 = OFF ; Disabled WRT2 = OFF ; Disabled WRT3 = OFF ; Disabled WRTB = OFF ; Disabled WRTC = OFF ; Disabled WRTD = OFF ; Disabled EBTR0 = OFF ; Disabled EBTR1 = OFF ; Disabled EBTR2 = OFF ; Disabled EBTR3 = OFF ; Disabled EBTRB = OFF ; Disabled Config_End Reminders true All_Digital = true Xtal 8 'OSCCON.6=1 '*************************** 'OSCCON.5=1 '**************************** 'OSCCON.4=1 '************************* 'OSCTUNE.6=1 ' enable PLL 32mhz! 'Declare PLL_Req = On LCD_Type = graphic LCD_DTPort PORTB LCD_RWPin PORTC.0 LCD_CS1Pin PORTC.1 LCD_CS2Pin PORTC.2 LCD_ENPin PORTC.3 LCD_RSPin = PORTA.3 'LCD_RSTPin = PORTD.1 '?????????????????????????RST 'GLCD_CS_Invert = 1 '**************************** 'Declare GLCD_STROBE_DELAY 10 '************************** 'Declare GLCD_READ_DELAY 2 '************************* 'DECLARE LCD_DATAUS 255 Internal_Font = On Font_Addr = 0 Stack_Size = 4 Symbol BLUE PORTA.0 Symbol RED PORTA.1 Symbol GREEN PORTA.2 Symbol LED PORTA.4 Symbol buzzer PORTA.5 Dim N As Byte Dim XPOS As Byte 'High buzzer 'While OSCCON.2 = 0 'Wait for OSC to stabalize DelayMS 200 'DelayMS 1 'Wend 'Low buzzer 'For N = 0 To 5 'High LED 'DelayMS 500 'Low LED 'DelayMS 500 'Next 'has rgb led backlight 'Low RED 'Low BLUE 'Low GREEN 'High LED 'DelayMS 4000 MAIN: Cls Low LED DelayMS 1000 Print At 0,0,"Wohoo! It works now!!" Print At 1,0," This Is Cool!" High LED DelayMS 2000 Cls DelayMS 1000 Low LED For XPOS = 0 To 63 Print At 5,2,Dec3 XPOS LCDWrite 4 , XPOS, [%11111111] DelayMS 100 LCDWrite 4 , 127-XPOS, [%11111111] DelayMS 100 Next DelayMS 1000 For XPOS = 0 To 63 Print At 5,2,Dec3 XPOS LCDWrite 5 , XPOS, [%11111111] LCDWrite 5 , 127-XPOS, [%11111111] DelayMS 100 Next Circle 1,10,10,5 Circle 1,30,30,10 Low LED DelayMS 1000 GoTo MAIN Include "FONT.INC" |
|
|
|
|
|
#20 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Thank you for your help Bob but it must be defective or I am just wiring it incorrectly.
I tried your code and it still is the same way. I also switched to a external 10mhz xtal. As I am typing this message I have been closely examining the GLCD's circuit board and I see a blemish right next to the quality control sticker. It looks like 15 or so traces were printed across a 1/4 inch long hair and I think it is defective. Regards, Jon |
|
|
|
|
|
#21 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
Hi guys, attached are 2 photos of the manufacturing error. it was barely visible to the eye but with the camera you can see it clearly. notice the quality control sticker!
![]() I'm surprised that it worked at all. Now I feel that I have wasted your time and want to apologize. I do appreciate all of your help with this and I have learned an whole lot about these GLCD's now! Thank you very much. I have sent a message to crystalfontz regarding the flaw, and sent some pictures too. When I get the replacement, I have 3 prewired breadboards awaiting it.
|
|
|
|
|
|
#22 |
|
Licensed User
![]() Join Date: Aug 2005
Location: Kent.
Posts: 1,477
![]() |
Hi,
It wasnt a total waste as there were errors in the code as well but a defective screen does not help. The best advice I can give is look at one of the free VSM boards and wire it up exactly as that, then you can test simulate your code beforehand. Regards, Bob |
|
|
|
|
|
#23 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
I thought I'd give you an update regarding this GLCD,
It is a model CFAG12864A-CFH-TA from Crystalfontz.com I would recommend against buying it unless you only want to run it slowly. Crystalfontz sent me a new one and let me keep the old one. the exchange took 5 days. While I was waiting, I soldered the broken traces up and tried it again with the same results. I also ordered a pic24f starter kit from Sure Electronics http://www.sureelectronics.net/goods.php?id=978 . It comes with a 128x64 GLCD and the total cost was $40usd + shipping. When I received the replacement GLCD from Crystalfontz, I checked it for defects and then connected it to my circuit and got the same disappointing results. it only worked when at 4 mhz. Then I tried using it from mikroC, set to use the 10mhz HS osc. It worked but got pretty bad when I started the PLL. I don't know enough about mikroC to be sure that it was really running the PIC at 10mhz or 40mhz with pll. Then the pic24F starter kit arrived so I put the Crystalfontz GLCD on the starter kit and just got garbage. So I connected the GLCD from the starter kit to my proton programmed pic18F4620 and it works just fine, even at 40mhz. - except the circle function just draws spots. So I conclude that the glcd from Crystalfontz is kind of useless. It's lcd engage and disengage time is better than the one from the starter kit though. as when you are animating, the starter kit glcd blurs much worse. On the bright side, I now have 2 crystalfontz GLCDs for the price of one, that only take commands when the PIC is at 4mhz ![]() Regards, Jon |
|
|
|
|
|
#24 |
|
Licensed User
![]() Join Date: Mar 2003
Location: Knaresborough, N.Yorks
Posts: 79
![]() |
Are you sure that is a manufacturing error, have you checked to see if it is a short. It just looks like what we see with some of our boards - Some erroneous Solder Resist.
Phil. |
|
|
|
|
|
#25 |
|
Licensed User
![]() Join Date: Oct 2005
Location: Crime riddled ZA
Posts: 7,495
![]() |
Same as Phil I doubt if it would be the display or the pic or the pic's speed. I think there's a misconnection or another problem you oversee.
Check the operating voltage of the pic and that of the GLCD. They should be the same. Check connections one by one and tediously betweeen the pic and lcd. One error and it won't work. Make sure in the s/ware everything is defined correctly. Little things have big effects. The problem is not the pic or the LCD, it's something else. |
|
|
|
|
|
#26 |
|
Licensed User
![]() Join Date: May 2005
Location: Western Washington
Posts: 58
![]() |
One variable that hasn't changed is the solder that I used when I soldered the male pins to each of the 2 GLCD's.
I suppose that I could suck off the old solder and use a different solder but I haven't had trouble from the solder before. The solder jobs look good. On one of the GLCD's I re soldered it (with the same solder spool) but it didn't help. The solder that I used is "Radio Shack High-Tech Rosin-Core, Silver-Bearing solder 62/36/2". On the 2nd GLCD, I left a little bit of flux between the solder points. I don't think that is a problem since I did tidy it up on the first GLCD and it didn't help. I am still learning though and don't know for sure. All times that I tried, the GLCD's have been plugged into solderless breadboards though. I've used different brand breadboards, different types of wires, different power supplies and different PIC models. It would be a relief if this problem is my fault & I could straighten it out. Regards, Jon |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PIC control via SMS using SIEMENS mobile phone | naruto | GSM / SMS | 21 | 30th January 2010 16:49 |
| GLCD Load on PIC | citldave | Proton Plus v2.1.5.3 General Discussion | 7 | 5th March 2009 22:01 |
| Samsung GLCD works on 16F876A, not on 16F886 | Wim26 | Proton Plus Compiler v3 | 19 | 17th April 2008 16:00 |
| Compiler updated & PIC program no longer works | Ian-Stevenson | Proton Plus Compiler v3 | 2 | 15th January 2008 07:39 |
| Pic to Pic Talking | the.fox | Proton Plus v2.1.5.3 General Discussion | 5 | 2nd January 2003 20:33 |