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

HELP with PIC18F4620!!

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



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

HELP with PIC18F4620!!
PostPosted: Fri Mar 03, 2006 10:27 am     Reply with quote

Mad
Hi I just ported some code that I had in the past working perfectly with the PIC18F452 to the new PIC18F4620. I had previously no problems moving this code around with the PIC18F4XX family.
It appears that my application using a standard 2X16 character lcd no longer works (using CCS lcd.c) I had always used port D for the LCD control and data and although the hardware signals appear to work OK on the new PIC, I only get all pixxels on across the entire display.
I have read the data from Microchip regarding the migration to these new devices, but I cant seem to see anything that should have anything to do with the operation of port D. I have eliminated the #zero ram from my code (I am using the latest PCH3.245 and ICD 1.38) and tried various things like #fast io but no luck!.
HAS ANYONE ELSE ENCOUTERED LCD INTERFACE PROBLEMS USING THIS DEVICE??
Any hints would be greatly appreciated!
Thank you all
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Fri Mar 03, 2006 10:46 am     Reply with quote

I had code that worked on 18F258 compiled with PCH 3.223, moved to an 18F2680 compiled with PCH 3.242 and it did some strange things. Installed PCH 3.236 and re-compiled and it now works ok again.

So try 3.236, CCS have done a lot of 'optimization' changes since then for the new 24Fxxxx series and seem to be introducing bugs.

I still have a 4 week old bug report with them on this one which has 'yet to be assigned a priority' !!

Here is my original posts on this :

http://www.ccsinfo.com/forum/viewtopic.php?t=26107
_________________
Regards,
Simon.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 03, 2006 12:20 pm     Reply with quote

Thanks for the help.
I tried going back to ver 3.326 and recompiled, unfortunately the problem still exist. So it appears not be related to an optimazation bug on the compiler. There has to be some fundamental difference which I am not yet aware. Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 03, 2006 12:33 pm     Reply with quote

Post the smallest possible program that shows the problem.
Make it be a complete program, showing all #include, #fuses, and
#use statements, but limit it to only a few lines in main().
If you have an LCD problem, you should be able to make a
demo program with just lcd_init(), lcd_putc(), and a while(1);
at the end. Make the program be that short, or close to it.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 03, 2006 2:39 pm     Reply with quote

Thank you PCM programmer
Here is a simple test file without the rest of the stuff (that still does not work with the LCD)

/////////////////////////////////////////////////////////////////////////////////////
#include <18F4620.h>
#device ICD=TRUE
#device adc=10

#FUSES WDT128, HS, NOPROTECT, DEBUG, NOLVP, NOWRT,NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, PBADEN, LPT1OSC, MCLR

//#fuses HS,PUT,BROWNOUT,WDT128,NOLVP,NOWRT,DEBUG,STVREN // for ICD
//#fuses HS,PUT,BROWNOUT,WDT128,NOLVP,NOWRT,NODEBUG,STVREN,BORV42,NOOSCSEN // from previous

#use delay(clock=10000000,RESTART_WDT)
//#USE DYNAMIC_MEMORY

//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

#use fast_io(D)

// Using the standard CCS LCD.C disp driver defined in the following structure the pin connection is as follows:
// D0 RS
// D1 RW
// D2 E
// D3 Not used
// D4 D4
// D5 D5
// D6 D6
// D7 D7
// then the whole stucture is placed on port D (#byte lcd = 0xF83)

#byte port_a = 0xF80
#byte port_b = 0xF81
#byte port_c = 0xF82
#byte port_d = 0xF83
#byte port_e = 0xF84

void init()
{
set_tris_a(0x01);
set_tris_b(0xFF);
set_tris_c(0x90);
set_tris_d(0x0F);
set_tris_e(0xf0);
setup_psp(PSP_DISABLED);
port_b_pullups(TRUE);
setup_adc_ports(AN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
set_adc_channel(0);

//setup_wdt(WDT_ON);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); //will overflow at 38Hz or every 26.2mS
//setup_timer_2(T2_DISABLED,0,1);
setup_timer_2(T2_DIV_BY_4,255,1); // generates pwm freq of 2.44KHz with 10 bit res
//setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
//setup_ccp1(CCP_PWM_HALF_BRIDGE|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L); //???
setup_ccp1(CCP_PWM);
disable_interrupts(INT_CCP1); //unmask capture 1 interrupt
//enable_interrupts(INT_TIMER0);
disable_interrupts(INT_TIMER0);
disable_interrupts(INT_TIMER1);
ext_int_edge(H_TO_L);
disable_interrupts(INT_EXT);
//enable_interrupts(INT_EXT1);
disable_interrupts(INT_EXT1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_low_volt_detect(FALSE);
setup_oscillator(False);
//enable_interrupts(INT_RB);
//disable_interrupts(INT_EXT1);
//enable_interrupts(GLOBAL);
disable_interrupts(GLOBAL); }



void main()
{

init();

lcd_init();

do {
lcd_putc("\f");
delay_ms(1000);
lcd_gotoxy(2,1);
lcd_putc("Hello");
delay_ms(1000);
lcd_gotoxy(1,2);
lcd_putc("Cruel World"); } while(1); }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 03, 2006 2:44 pm     Reply with quote

I wouldn't call that a short program. Can't you strip it down
to just a few lines ?

At a minimum, you should have deleted all the commented lines.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 03, 2006 3:49 pm     Reply with quote

Hopefully this shorter:

#include <18F4620.h>
#device ICD=TRUE
#device adc=10

#FUSES WDT128, HS, NOPROTECT, DEBUG, NOLVP, NOWRT,NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, PBADEN, LPT1OSC, MCLR

#use delay(clock=10000000,RESTART_WDT)

#use fast_io(D)

// Using the standard CCS LCD.C disp driver defined in the following structure the pin connection is as follows:
// D0 RS -> I leave this here so you can see my lcd io pin config
// D1 RW
// D2 E
// D3 Not used
// D4 D4
// D5 D5
// D6 D6
// D7 D7
// then the whole stucture is placed on port D (#byte lcd = 0xF83)

#byte port_d = 0xF83

void init()
{
setup_psp(PSP_DISABLED);
port_b_pullups(TRUE);
setup_adc_ports(AN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
set_adc_channel(0);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DIV_BY_4,255,1);
setup_ccp1(CCP_PWM);
disable_interrupts(INT_CCP1);
disable_interrupts(INT_TIMER0);
disable_interrupts(INT_TIMER1);
ext_int_edge(H_TO_L);
disable_interrupts(INT_EXT);
disable_interrupts(INT_EXT1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_low_volt_detect(FALSE);
setup_oscillator(False);
disable_interrupts(GLOBAL); }



void main()
{

init();

lcd_init();

do {
lcd_putc("\f");
delay_ms(1000);
lcd_gotoxy(2,1);
lcd_putc("Hello");
delay_ms(1000);
lcd_gotoxy(1,2);
lcd_putc("Cruel World"); } while(1); }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 03, 2006 4:09 pm     Reply with quote

Your code doesn't show the #include statement for the LCD.C file,
so it doesn't compile.
----------------------------
Also:

Are you using the LCD.C driver file, without any modifications to it ?

Here are your connections to the LCD:
Quote:

// D0 RS
// D1 RW
// D2 E
// D3 Not used
// D4 D4
// D5 D5
// D6 D6
// D7 D7


Below, I've posted the connections listed in the CCS LCD.C file.
Quote:

// D0 enable
// D1 rs
// D2 rw
// D4 D4
// D5 D5
// D6 D6
// D7 D7


Notice how you have moved the Enable, RS, and RW signals to
different pins than are used in the CCS driver. If you haven't
modified the CCS driver, then it won't work with your connections.
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 03, 2006 4:57 pm     Reply with quote

Thanks for your help, Actually I did modify the CCS lcd.c file so my re-arrangenment does work as I have been using this driver file with the PIC18F452 all along.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 03, 2006 5:03 pm     Reply with quote

Try the test program shown below. This is what I meant when I said
to post a small program:
Code:
#include <18F4620.h>
#fuses HS, NOWDT, NOPROTECT, PUT, NOLVP
#use delay(clock=10000000)

#include <lcd.c>   // Use your modified LCD.C file here.

void main()
{
lcd_init();

lcd_putc("Hello World");

while(1);
}
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 06, 2006 11:39 am     Reply with quote

Very Happy
Thank you all so much for your help.

The reason as to why my LCD display would not work had nothing to do with the code or the new PIC , it turned out to be a logic collission within two of the data bits, otherwise known as a "short" Even though I trouble shot this thing for hours, I could not see the problem until I had a logic analyzer tied to it.

Embarassed Embarassed
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