Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 11th March 2008, 02:15 AM   (permalink)
Default 18F2520 Oscillator settings

Hello, I am trying to use an 18F2520 with a GLCD and it seems to be running really slow. The GLCD fill command takes about 5-7 seconds to finish. Here is the code that I am using with the mikroC compliler.

Code:
void main()
{
     TRISA = 0xff;
     TRISB = 0x00;
     TRISC = 0x00;
     PORTB = 0x00;
     PORTC = 0x00;
     ADCON1 = 0x0f;
     OSCCON = 0x07;
     OSCTUNE = 0x40;
     
     Glcd_Init(&PORTC,1,0,2,4,6,5,&PORTB);
     Glcd_Fill(0);
     Glcd_Set_Font(FontSystem5x8, 5, 8, 32);
     Glcd_Write_Text("TEST",0,0,1);
}

I am also using the default project fuses. Thanks
superbrew is offline  
Old 11th March 2008, 02:29 AM   (permalink)
Default

What crystal are you using?
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 11th March 2008, 02:37 AM   (permalink)
Default

Doing OSCCON = 0x07 selects the internal oscillator at 32kHz. Try OSCCON = 0x72 for the internal 8MHz clock or OSCCON = 0x00 if you have an external crystal. If you have an external crystal then you may have to set the fuses appropriately.

Mike.
Pommie is online now  
Old 11th March 2008, 02:49 AM   (permalink)
Default

Unbelievable!
The OSCCON was supposed to be set to 0x70, not 0x07. Thanks so much for noticing that.

It works perfectly now, thanks.
superbrew is offline  
Old 11th March 2008, 03:06 AM   (permalink)
Default

It's amazing how often the error is a simple typo but almost impossible to spot without a fresh set of eyes.

Mike.
Pommie is online now  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:29 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker