CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18F4550 + LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Pichuqy_1



Joined: 03 Aug 2010
Posts: 38

View user's profile Send private message MSN Messenger

PIC18F4550 + LCD
PostPosted: Wed Sep 05, 2012 1:44 pm     Reply with quote

Hi! I have a big problem. I'm trying to use this microcontroller with a graphic lcd but it doesn't work. I don't know why. I'd tried with everything, if I use the same code with other pic it does works perfectly. I'm using a 12 MHz crystal. Can someone help me please?

Code:
#include "18F4550.h"
#device adc=10
#fuses HSPLL,MCLR,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL3,CPUDIV1,NOVREGEN,NOPBADEN
#use delay(clock=48000000)

#define _HDM64GS12_modificada
#define GLCD_CS1         PIN_E0
#define GLCD_CS2         PIN_E1
#define GLCD_DI        PIN_E2
#define GLCD_E          PIN_D0
#define GLCD_RW          PIN_D1
#define GLCD_RST        PIN_D2


#include <HDM64GS12_modificada.h>
#include <GRAPHICS_modificada.c>


char valor_date[10];
char valor_lm35[5];
char segundo[3];
long medicion;
char configuracion_hora[ ]="Configurar HORA --> *";
int cont=0,un_segundo=0;
int cambio=0;


                              
void main(void)
{

   setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
   set_timer1(0);
   enable_interrupts(INT_TIMER1);                     
   enable_interrupts(GLOBAL);

   setup_adc_ports (AN0);           
     setup_adc (ADC_CLOCK_INTERNAL);                                
     set_adc_channel(0);                                          
     delay_us(10);

                              


#rom int8 0xF00004={'1','2','3','4'};               
                                          
                                  

glcd_init(ON,SelGLCD_1);


glcd_text57(0,57,configuracion_hora,1,1,SelGLCD_1);         

do{ 
glcd_text57(0,57,configuracion_hora,1,1,SelGLCD_1);

}while(TRUE);
}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Sep 05, 2012 2:25 pm     Reply with quote

Hi,

It looks like your #use delay statement and/or your fuses are incorrect for
the crystal you indicate. I would connect an LED (thru a suitable current
limiting resistor) to one of the PIC I/O pins, and try to flash it at a
predictable rate, say 1 second ON, and 1 second OFF. I think you'll find it's
not predictable with your current settings, and crystal combination.

John
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Thu Sep 06, 2012 2:16 am     Reply with quote

The clocks look OK.

On the 4550, you have the choice of running the CPU, from the USB PLL, or from the main oscillator. This is controlled by selecting HS or HSPLL (the PLL _always_ runs).

So HSPLL, is saying take the master oscillator from the USB PLL.

This PLL requires a 4MHz input, so 'PLL3' (clock coming in/3 feeds the PLL).

Then CPUDIV1, says take the USB clock/2 (the CCS naming is really annoying, since the actual 'divisor' given is different when running from the external crystal, and the USB PLL), with CPUDIV1, giving /1 from the main crystal, or /2 from the USB PLL. CPUDIV2 gives /2 from the main crystal, but /3 from the USB PLL etc...

The USB PLL, gives 96MHz, so the fuses as specified should give 48MHz operation.

However the code is extremely messy (things like #ROM statements to program the EEPROM, in the middle of the main routine - uurgh).

I'd guess:
1) MCLR?.
2) (Most likely), not turning off the other peripherals on the pins being used. Streaming parallel port is on these pins.
3) General comment, is ADC_CLOCK_INTERNAL, legal at 48MHz?. (no it isn't - select the recommended clock).

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group