Page 1 of 1

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

Posted: 04 Jun 2010 13:25
by crocu
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);

   }

}

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

Posted: 06 Jun 2010 11:55
by piort
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 ;-)

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

Posted: 06 Jun 2010 13:39
by crocu
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

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

Posted: 06 Jun 2010 17:49
by piort
hi
chk for PBADEN ...
sorry i dont remember how is the setup window for no-pro version :oops:

hth a bit ;-)

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

Posted: 06 Jun 2010 17:58
by crocu
Thanks, i found this in the list :

PBADEN_OFF_3H = $00FD
PBADEN_ON_3H = $00FF

Should i set : PBADEN_ON_3H ?

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

Posted: 06 Jun 2010 18:06
by piort
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 )))))

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

Posted: 08 Jun 2010 16:01
by tihomir.losic
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