pic18F97j60

Status
Not open for further replies.

lakis

New Member
hi guys i'm new in this area and i have to do a project using pic18f97j60 (i'm using c18 compiler).Can someone tell me how to set the configuration bit ?

i thing is
#pragma config XINST=OFF, WDT=OFF, FOSC2=ON, FOSC=HSPLL

but i 'm not sure
 
Here is something I found lying around, from playing around a long time ago:

Code:
//	18F97J60 Configuration Registers
#pragma	config	XINST = OFF			// do not use extended instructions
#pragma	config	STVR = OFF			// stack overflow off
#pragma	config	WDT = OFF			// HW Disabled - SW Controlled
#pragma	config	CP0 = OFF		    // code protection block 0
#pragma	config	FCMEN = OFF         // Fail-Safe Clock Monitor disabled
#pragma	config	IESO = OFF          // 2 speed startup
#pragma	config	FOSC2 = ON			// primary oscillator by default
#pragma	config	FOSC = HSPLL        // HS oscillator, PLL enabled, HS used by USB
#pragma	config	WDTPS = 1       	// WDT off, so who cares
#pragma	config	WAIT = OFF      	// Ext Mem buss - don't care
#pragma	config	BW = 8  			// Ext Mem buss - don't care
#pragma	config	MODE = MM		    // Ext Mem bus disabled
#pragma	config	EASHFT = OFF	    // Ext Mem buss - don't care
#pragma	config	ETHLED = OFF        // RA0, RA1 are IO, not ethernet LED
#pragma	config	ECCPMX = OFF		// ?
#pragma	config	CCP2MX = OFF		// ?
Don't know if it is of use, but it is free.
 
Lcd 2x16 to pic18f97j60

HI guys i am drying to connect the LCD (L2012) with pic18f97j60
this is is the code i try

#include <stdio.h>
#include <P18f97j60.h>
#include <delays.h>
#include <timers.h>

#pragma code page // This code make sure the program starts from 0x0004, not from 0x0000
#pragma config WDT = OFF,WDTPS = 128
#pragma config STVR = OFF
#pragma config DEBUG = ON
#pragma config CP0 = OFF
#pragma config FOSC=HS


#define RS PORTFbits.RF3
#define dirRS TRISFbits.TRISF3
#define RW PORTFbits.RF0
#define dirRW TRISFbits.TRISF0
#define E PORTFbits.RF1
#define dirE TRISFbits.TRISF1
#define DATALCD PORTE
#define dirDATA TRISE
#define LCDBusy PORTEbits.RE7



void LCDdata (unsigned char);
void busylcd(void);
void LCDinit (void);
void LCDDelay( void );
void lcdcmd(unsigned char);
void stringtoLCD(unsigned char *m);
unsigned char * itoa (unsigned int value, unsigned char * string);

unsigned char dataString[10];
char data[]="GEO";


void main (void) // main function
{

int integer,i,integer1;
unsigned char *biginin;
i=0;


biginin=&dataString[0];
TRISE = 0;
PORTE = 0;

dirRS = 0;
LCDinit();

while (1) // this is how to make a never ending loop.
{
lcdcmd(0x1);
lcdcmd(0x2);
LCDDelay();

i++;
integer=i;
LCDDelay();
itoa (integer, biginin);
stringtoLCD(dataString);
lcdcmd(0xC0);

LCDDelay();

stringtoLCD(data);
}
}

//////////////////////////////////////////////////////////////////////////////////////
//LCD finctions------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////
void LCDdata (unsigned char value)
{
busylcd();
TRISE = 0;
DATALCD = value;
RS=1;
RW=0;
E=1;
LCDDelay();
E=0;

}
//--------------------------------------------------------------------------------------
void LCDinit(void)
{
TRISF=0;
lcdcmd(0x38); //set 8-bit mode and 2 lines
lcdcmd(0x10); //cursor move & shift left
lcdcmd(0x06); //entry mode = increment
lcdcmd(0x0d); //display on - cursor blink on
lcdcmd(0x01); //clear display
}
//-------------------------------------------------------------------------------------
void busylcd(void)
{
RS=0;
RW=1;
TRISE=255;
E=0;
LCDDelay();
E=1;
while(LCDBusy==1){
E=0;
LCDDelay();
E=1;
}
}
//-------------------------------------------------------------------------------------
void lcdcmd(unsigned char temp)
{
busylcd();
RS=0;
RW=0;
TRISE=0;
DATALCD=temp;
E=1;
LCDDelay();
E=0;
}

//--------------------------------------------------------------------------------------
void LCDDelay(void)
{
int i=0;
for (i=0;i<250;i++);

}
//---------------------------------------------------------------------------------------
void stringtoLCD(unsigned char *m)
{
unsigned char i;
i = 0;
while(m != 0)
{
LCDdata(m);
i++;
}

}


although BUILD SUCCEEDED the only thing i get is a line of boxes
 
You can't read the busy flag until the unit's function set has been accepted.... I send 0x33 WITHOUT checking anything else twice.

Put 0x33 on the LCD port ( RW and RS low) then clock the E line.... wait 20ms then clock again.... then send 0x38... 0x10... etc..
 
Last edited:
Ian Rogers thanks for answer .
i will try that.
something else when i try to debug the program i get

ICD3Err0040: The oscillator is not working. Check your Configuration bits setting for the
oscillator.

should i change the way i set Fosc or some else configuration bit?
 
What Osc are you using? internal or external? Are you using a dev board?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…