Pb : Simple LCD test code and 18F2620 : maybe wrong fuses ?

General discussion on mikroC.
Post Reply
Author
Message
crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

Pb : Simple LCD test code and 18F2620 : maybe wrong fuses ?

#1 Post by crocu » 04 Jun 2010 13:25

Hello

I'm using a 18F2620 with 10 Mhz crytal + 2 x 18pf caps.

I connected on port B a LCD and only would like to display a test message on it.

When powering up the Pic initialises the LCD but nothing is been displayed.
I think there is something wrong with my fuses settings.

Can you tell me what i should set in my project settings ?

Here are what is currently selected :

OSC_HS_1H
LVP_OFF_4L
XINST_OFF_4L

Many thanks for your help,

Code: Select all

/*******************************************************************************
                LCD Test for 18F2620
                  10 Mhz Crystal

Hardware configuration :
LCD RST  = RB2
LCD E    = RB3
LCD D4   = RB4
LCD D5   = RB5
LCD D6   = RB6
LCD D7   = RB7
*******************************************************************************/

// Initialisations

// Definition for Inputs & Outputs :

#define LCD_BL PORTB.F1   // LCD Back light

void Init(void)
{

ADCON1 = 0x0E;  // Set AN0 channel pin as analog
ADCON1 = 7;     // Configure AN pins as digital I/O

// For AN -> Dig conversion :

  TRISA = 0B11001111;
  ADCON1= 0x82;         // configure VDD as Vref, and analog channels

  PORTB = 0x00;         //initialize PORTB
  TRISB = 0;

  PORTC = 0x00;
  TRISC = 0B11000000;   // RC6 & RC7 : inputs - RC0 to RC5 : outputs


  //Lcd_Config(&PORTB, 0, 1, 7, 5, 4, 3, 2);
  Lcd_Init(&PORTB);
  Lcd_Cmd(LCD_CLEAR);       // Clear display
  Lcd_Cmd(LCD_CURSOR_OFF);  // Turn cursor off
 }


//----------------------------------------------------------------------------------
void main()
//----------------------------------------------------------------------------------
{


   Init();       	 // Initialize Pic ( pins & lcd )
   LCD_BL = 1;      // Switch the LCD back light ON


   while(1)         // boucle infinie
   {

   Lcd_Custom_Out(1, 5, "Hello!");                 // Print “Hello!” on LCD at line 1, char 5
   Lcd_Custom_Out(2, 3, "test display !");
   

  //----------wait approx. 1.2s 

     Delay_ms(1200);

   }

}

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#2 Post by piort » 06 Jun 2010 11:55

hi,
chk in edit projet windows and set RB4 to digital...is analog input by default and you cant set that in code

hth a bit ;-)

crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#3 Post by crocu » 06 Jun 2010 13:39

Thanks, but i can't find where i should change RB4 in Edit Project window ...

Is it in the device flag list ?

How it is called ?

I'm using MikroC for PIC , version: 8.2.0.0

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#4 Post by piort » 06 Jun 2010 17:49

hi
chk for PBADEN ...
sorry i dont remember how is the setup window for no-pro version :oops:

hth a bit ;-)

crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#5 Post by crocu » 06 Jun 2010 17:58

Thanks, i found this in the list :

PBADEN_OFF_3H = $00FD
PBADEN_ON_3H = $00FF

Should i set : PBADEN_ON_3H ?

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#6 Post by piort » 06 Jun 2010 18:06

hi,
from the datasheet
Configuration on POR is determined by the PBADEN Configuration bit. Pins are configured as analog inputs by default
when PBADEN is set and digital inputs when PBADEN is cleared.
in fact , if unsure, try both )))))

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: Pb : Simple LCD test code and 18F2620 : maybe wrong fuse

#7 Post by tihomir.losic » 08 Jun 2010 16:01

Hello,

please, try this code. I tested that on EasyPIC6 and didn't have errors.
You only need to change line LCD_Custom_Config because you have
different schedule of pins.

Code: Select all

void main()
{
     ADCON1 = 0x07;             // Configure AN pins as digital I/O
     CMCON = 0x07;
   
     Lcd_Custom_Config(&PORTB,3,2,1,0,&PORTB,4,6,5);
     Lcd_Custom_Cmd(LCD_CLEAR);                         // Clear display
     Lcd_Custom_Cmd(LCD_CURSOR_OFF);                    // Turn cursor off

   while(1)         // boucle infinie
  {
      Lcd_Custom_Out(1, 5, "Hello!");                   // Print “Hello!” on LCD at line 1, char 5
      Lcd_Custom_Out(2, 3, "test display !");
      Delay_ms(100);
  }
}
Best regards,

Losic Tihomir
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”