Bug with GLCD and 18F4685 ( with EasyPic5 )

General discussion on mikroPascal.
Post Reply
Author
Message
Philippe456
Posts: 6
Joined: 19 Jun 2008 11:52
Location: France

Bug with GLCD and 18F4685 ( with EasyPic5 )

#1 Post by Philippe456 » 19 Jun 2008 13:19

Hello, I'm trying to connect a GLCD with a 18F4685 on a easyPic5 board.
I take the 18F4520 exemple, just change the processor, and add a ECCP1CON:=0 in the program ant set the config words.

The problem is that not all pixels are drawned on the screen :shock:

I test with a line from 0,0 to 0,63 : 4 pixels are drawn , 4 are not , 4 are drawn, ....

Image

Code: Select all

// *

// *

// * Project name:

//    Glcd_Test

// * Copyright:

//     (c) mikroElektronika, 2008

// * Revision History:

//     20080225:

//       - initial release.

// * Description:

//    This is a simple demonstration of the GLCD library routines:

//     - Init and Clear (pattern fill)

//     - Image display

//     - Lines, circles, text etc.

// * Test configuration:

//     MCU:             PIC18F4520  --> test with 18F4685

//     Dev.Board:       EasyPIC5

//     Oscillator:      HS, 8.000 MHz

//     Ext. Modules:    None

//     SW:              mikroPascal v8.1

// * NOTES:

//     - to turn ON Glcd backlight switch 'GLCD' on SW9 (board specific)

// *



program Glcd_Test;



uses __Lib_images;



var

  ii : byte;

  jj : word;

  someText : string[25];



procedure delay2S;

begin

  delay_ms(2000);                               // 2 second delay procedure

end;



begin

  INTCON := 0;                                  // disable all interrupts

  ADCON1 := 0x0F;                               // configure PORTB pins as digital

  ECCP1CON:=0;

  Glcd_Init(PORTB, 0, 1, 2, 3, 5, 4, PORTD);    // Glcd_Init_EP5, see Autocomplete

  Glcd_Fill(0xAA);

  delay2S;



  while TRUE do

    begin

      Glcd_Fill(0x00);                          // clear screen

      Glcd_Image(truck_bmp);                    // display image from library

      delay2S;                                  // call to 2 second delay procedure



      Glcd_Fill(0x00);                          // clear screen

      

      Glcd_Line(0, 0, 0,63, 1);               // write line with given cordinates

      delay2S;

      

      



      for jj := 1 to 50 do                      // writing a line using for loop

        Glcd_Dot(jj, jj, 1);

      delay2S;



      Glcd_Line(120, 1, 5,60, 1);               // write line with given cordinates

      delay2S;

      Glcd_Line(12, 42, 5,60, 1);

      delay2S;



      Glcd_Rectangle(12, 20, 93,57, 1);         // write rectangle on screen

      delay2S;



      Glcd_H_Line(5, 15, 6, 1);                 // write horizontal line with given cordinates

      Glcd_Line(0, 12, 120, 60, 1);

      Glcd_V_Line(7, 63, 127, 1);               // write vertical line with given cordinates

      delay2S;



      for ii := 1 to 10 do                      // write concentric circles using for loop

        Glcd_Circle(63, 32, 3*ii, 1);

      delay2S;



      Glcd_Box(12, 20, 70, 57, 2);              // write box on screen with given cordinates

      delay2S;



      Glcd_Fill(0x00);                          // clear screen



      Glcd_Set_Font(@FontSystem5x8, 5, 8, 32);  // initialize Font 5x8

      someText := 'Fonts Demo: 5x8';

      Glcd_Write_Text(someText, 5, 3, 1);       // write test

      delay2S;



      Glcd_Set_Font(@System3x6, 3, 6, 32);      // initialize Font 3x6

      someText := 'SMALL FONT: 3X6';

      Glcd_Write_Text(someText, 20, 5, 1);      // write test

      delay2S;                                  // call to 2 second delay procedure

    end;

end.
What am i missing ?

Thank you for your help :?:

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Bug with GLCD and 18F4685 ( with EasyPic5 )

#2 Post by zristic » 19 Jun 2008 13:36

Data port (PORTD) is not properly initialized to be fully digital.
Have a look at PDF for 18F4685 for finding information about how to make PORTD to be fully digital.

Philippe456
Posts: 6
Joined: 19 Jun 2008 11:52
Location: France

#3 Post by Philippe456 » 19 Jun 2008 15:49

i have checked the datacheet ( 39761b) but on page 140 there is :



TABLE 10-8: SUMMARY OF REGISTERS ASSOCIATED WITH PORTD

PORTD(1) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 52

LATD(1) LATD Data Output Register 52

TRISD(1) PORTD Data Direction Register 52

TRISE(1) IBF OBF IBOV PSPMODE ó TRISE2 TRISE1 TRISE0 52

ECCP1CON(1) EPWM1M1 EPWM1M0 EDC1B1 EDC1B0 ECCP1M3 ECCP1M2 ECCP1M1 ECCP1M0 51



Nothing about CMCON !!!



So after exploring the datasheet, I add CMCON:=%00000111 and it work fine.



Thank you very much for your help.

Jack Flanders
Posts: 337
Joined: 17 Apr 2008 02:53
Location: Fantasy Land

#4 Post by Jack Flanders » 27 Jun 2008 03:37

Philippe456,

Don't feel bad! You and I and many others are victims of Microchips poorly written datasheets. The information *is* all there but you have to read and read and read to find it. I just went over it and found out what is up.

In the section on ports, for example, they finish up each section with a table such as this one:

TABLE 10-8: SUMMARY OF REGISTERS ASSOCIATED WITH PORTD

which has NO entry for CMCON!!! :evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil:

so you feel like you have done your homework and checked all the registers that they say have anything to do with PORTD. But they are liars. If you do a search through the datasheet on "CMCON" you will find that the comparator settings involve, among many other things, PORTD!!!

Why do I write all this? Because I just spent the last 10 days with the same symptoms that you had. I saw your posting and zristic's answer today. When I got home from work, I typed CMCON = 0X07 and BANG! IT ALL WORKS!!!

So thank you Philippe456 and than you zristic!!! My display is working and I can start having fun again.



:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D





No. The fine people at Microchip are not liars and they do make a fine product. But their datasheets do have some rough spots I wish they would fix. Meanwhile, I will try to remember to work harder to find out why my code does not run correctly when it seems that it should...

Alls well that ends well even if it takes 10 extra days :D :evil: :D :evil: :D :evil: :D

User avatar
milan
mikroElektronika team
Posts: 1013
Joined: 04 May 2006 16:36
Contact:

#5 Post by milan » 27 Jun 2008 08:17

Hi,

we have plans to make some kind of All-Digital function that will turn off ANs, Comparators and ExtBuses for every PIC MCU.

This job requires many datasheet readings and filling the database for PIC MCUs.

Please don't ask us when we will finish that job :)

daduggan
Posts: 11
Joined: 13 Feb 2007 04:20

#6 Post by daduggan » 27 Jun 2008 18:25

I also had the same problem with the CMCON. After reading this post the problem was fixed. but I spent over a week reading the docs and going through the LCD lib in debugger looking for an answer. I saw the default bits were 000 at boot and reset and assumed that it is off. Like the Analog default on setting the comparators are on at reset also. I spend more time trying to solve problems like this then I spend developing the projects. It's a good thing we can share our answers or we'll all mad over the same stuff.

BaCaRdi
Posts: 236
Joined: 21 Feb 2008 02:19

#7 Post by BaCaRdi » 30 Jun 2008 12:47

We all have been victims of the old CMCON = 0X07 or %111. I too had this issue but I was able to figure it out, after reading a post on a different forum.


When in doubt CMCON = 0X07...lol


-Marc
[size=109][color=Red][b]Error[/b]: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...[/color][/size]
[url=http://www.bacardiware.com]Information Underground[/url]

rce
Posts: 2
Joined: 11 Dec 2010 21:39

Re: Bug with GLCD and 18F4685 ( with EasyPic5 )

#8 Post by rce » 11 Dec 2010 21:48

...but if i want use GLCD and ADC INPUT? :oops:

Dev. Board: EasyPic6
MCU: 18F4685
GLCD and Touchscreen

I want display battery voltage on GLCD (and use touchscreen for navigate in my little program...) . If i use EasyPIC module (ADC INPUTS) on port RA2, the value il displayed on GLCD but my touchscreen is dead... Locked!

Why?
Pleas, help me! :oops:

rce
Posts: 2
Joined: 11 Dec 2010 21:39

Re: Bug with GLCD and 18F4685 ( with EasyPic5 )

#9 Post by rce » 13 Dec 2010 12:21

rce wrote:...but if i want use GLCD and ADC INPUT? :oops:

Dev. Board: EasyPic6
MCU: 18F4685
GLCD and Touchscreen

I want display battery voltage on GLCD (and use touchscreen for navigate in my little program...) . If i use EasyPIC module (ADC INPUTS) on port RA2, the value il displayed on GLCD but my touchscreen is dead... Locked!

Why?
Pleas, help me! :oops:
I've solved problem.

After ADC_Read() command, i've used ADC_Init() command.
Tochscreen work!

Post Reply

Return to “mikroPascal General”