Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18 Crystal Setup (easy)

Status
Not open for further replies.

bulldozer

Newbie level 1
Joined
Jun 9, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
Hello,

I am driving myself nuts over this trivial problem. The program execution is terribly slow! I am using HI-TECH compiler and simply using the LCD demo that came with the compiler. I have only added this main.c program:

Code:
#include <htc.h>
#include "lcd.h"

void
main(void)
{
   
     
      ADCON0=0; //turn off A/D
      PCFG0=0;PCFG1=1;PCFG2=1;PCFG3=1; //PORTA all digital, except RA0
      RBIE = 0; //Disable all PORTB Change interrupts
      GIE = 0; // Global interrupt enable
    lcd_init(FOURBIT_MODE);
    lcd_goto(0);    // select first line
    lcd_puts("12345678");
    lcd_goto(0x40);    // Select second line
    lcd_puts("Hello world");

    for(;;);
}

The LCD works fine, however I can visibly see the words being printed in DEBUG MODE ONLY. It does NOT run in "release" if I select programmer and flash it.

My config bits are all set to disabled. I have Oscillator set at "XT".

The crystal is shaped like a tin can and is 3.579545MHz. I verified this with an O-scope. I have also placed 20pF caps to the correct locations.

Why is it running so slow?
 

Just check with higher oscillator frequency. I guess PIC18 has internal oscillator just try for that also.

Regards
Chanchal

Added after 2 minutes:

It is running slow only on two condition.

1. Instruction execution is to slow because of oscillator frequency.

2. there will be some instruction which is taking more amount of time.

Just check in debug mode.
 

chanage XT to HS
i do have such a problem i solved it like this.
please write CONFIG word for more elaboration
 

Here is a screen shot:

qujuB.png

I can run the program, but I can literally see the LCD parsing each line.

I have tried multiple crystalls...right now I am using a 10MHz.

I would only need to set everything in the CONFIG BITS to get the oscillator right correct?


the PIC18F258 does not have an internal oscillator...so something is wrong with how it it receiving the signal. I have verified the crystalls with an O-scope so I'm not sure where I'm going wrong.

Thanks for your help.[/img]

Added after 3 hours 47 minutes:

OK,

I simply toggled one of the ports high and then low and I am measuring the output being only 625KHz......

Something is not right here....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top