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.

[SOLVED] CCS PIC C and LCD Interfacing with PIC16F877A

Status
Not open for further replies.
Actual i am having a good knowledge of Hi-Tech C Compiler and MikroC for PIC C compilers..

I had purchased a Development Board of PIC18F4550 which is having in-built boot loader...

New_PIC_Board.jpg

And in there user manual they are using CCS PIC C to program there board...
The code generated by MikroC doesn't works with this board..
This is due to the reason because the Code geneareted by Mikroc over-writes the Boot-Loader... thats why i can't program mikroC code in that.

Hi-Tech C works fine... with this board..
But problem is that i have to experiment with USB

Hi-Tech and USB (I don't Know)
MicrochipC18 (Microchip USB Framework)-->I don't understand how to use it to create my projects

MikroC (I had used its in-built libraries and experiment with USB in Proteus and it works fine..)

CCS also has in-built routines for USB thats why i want to use it..
But i feels that it is not a good compiler..

I am going back to Hi-Tech C and MikroC
and will find a way to use my MikroC code with my Development Board
 

I am not having a good Knowledge of Boot-Loaders..


When i write code in Hi-Tech C

the program doesn't get stored in starting address...
Ca.png

It gets started at
Ca.png


While the code generated by MikroC

the code starts at
Ca.png


I think this is the Problem

I don't know how to tackle with this..
This is for the first time i have seen bootloaders
 

CCS also has in-built routines for USB thats why i want to use it..
But i feels that it is not a good compiler..

I agree. While CCS Compiler has several faults, however their insistence to advocate the inclusion of C files in very disturbing.

The practice provides fertile ground for issues with duplicate definitions, declarations, and inclusions.

Novice programmers rarely implement the normal safe guards to prevent duplicate inclusions in their headers files, I cannot see them implementing the following in their C files:

Code:
#ifndef ADD_H_GUARD
#define ADD_H_GUARD
int add(int a, int b);
#endif

I am going back to Hi-Tech C and MikroC
and will find a way to use my MikroC code with my Development Board

If the bootloader is the issue, you can replace it with one of several available bootloaders.

Although, you most likely can use the bootloader already installed in the dev board, you just need to configure the compiler correctly to generate the correct type of code, Absolute or Relocatable, and if Absolute specify the correct starting address.

I have found both Hi-Tech and Microchip C Compilers the most compliant with Standard C, C89 and C99.

By the way, Hi-Tech is now owned by Microchip.

While I do own a MikroC Pro Compiler license, I rarely use it. I have found their customer support severely lacking. And you cannot purchase the source code for their libraries which make it unusable for most of my commercial development as per client requirements as well as my own. There are also other issues on noncompliance with Standard C, C89 and C99, however these are only of secondary concern.

However, I do consider MikroC Pro an appropriate C Compiler for the novice programmer.

Configuring a USB interface in CDC class is not difficult using the Microchip USB Framework and is compatible with the Hi-Tech C Compiler.

AN956 Migrating Applications to USB from RS-232 UART with Minimal Impact on PC Software

AN1164 USB CDC Class on an Embedded Device



You might consider installing a USB bootloader, there are several available as well.

Diolan USB PIC Bootloader PIC-BOOT



**broken link removed**

The following are example programs for the Microchip PICDEM Full Speed USB Development Board, PIC18F4550 based:

**broken link removed**



BigDog
 

By the way, Hi-Tech is now owned by Microchip.

For Pic18 microchip has its MicochipC8 compiler and Hitech has its own..
are they both same compiler..
i think no...
Okay i got when we install MPLAB IDE Hi-Tech C Compiler for PIC16F get automatically installed..

If the bootloader is the issue, you can replace it with one of several available bootloaders.

Although, you most likely can use the bootloader already installed in the dev board, you just need to configure the compiler correctly to generate the correct type of code, Absolute or Relocatable, and if Absolute specify the correct starting address.

I wanto use the BootLoader of my DeV Board...
So What to do now..
What is this Absoltute abd Relocatable code..
I have seen this when i had used Assembly Language..
When i assembly my code in Assembly Language. then it ask me to Absolue and Relocatable..

How can i use this with the BootLoader of my Dev Board
 

Here is very simple LCD working code . Just set pins according to your diagram in file lcd.c

#include <16f877a.h>
#use delay(clock=4000000)
#include <LCD.C>
void main()
{
lcd_init ();
printf (lcd_putc,"%s","LCD TEST");

}
---------- Post added at 20:58 ---------- Previous post was at 20:55 ----------
 

Here is very simple LCD working code . Just set pins according to your diagram in file lcd.c

#include <16f877a.h>
#use delay(clock=4000000)
#include <LCD.C>
void main()
{
lcd_init ();
printf (lcd_putc,"%s","LCD TEST");

}

Not Working :-(

I don't know what to do now...
:-(
 

I haven't used that...

Can you mail me the whole Design File and the project file...
I don't know why it is not working...
my email id is arunsharma0731@gmail.com

Mail me all files pls...
 

Its not working...
What a Compiler..
:-(

i am removing this compiler now..
I am frustrated..
i better i write my own functions in other free compilers..

Any thanks to all..


and engr.waqas thanks to you..
u tried to help me...
but i don't get it working...
i am remving this compiler..
 

hi guyz... new to this forum...

@arunsharma0731 , After following these threads and suggestions i found a modified lcd driver for ccs compiler with a test code to verify it from ccs forum. hope this may help..
 

Attachments

  • lcd.zip
    59.2 KB · Views: 97

@irshad9in : The driver and code I sent was working and tested. arunsharma0731's issue was he was unable to make project in CCS C , I solved this by taking his PC remote.
 
hi guyz... new to this forum...

@arunsharma0731 , After following these threads and suggestions i found a modified lcd driver for ccs compiler with a test code to verify it from ccs forum. hope this may help..

Attached Files Attached Files

File Type: zip lcd.zip (59.2 KB)

Hello!! Your code is working but why my one is not working.
I am using the driver file lcd.c that comes with ccs pic c.
Why this file is not working,
engr.waqas has taken my pc remote to solve my problem, but he uses his driver file.

But i want to know why the driver file that comes with CCS C "lcd.c" is not working..

I again write a simple code in MPLAB for CCS PIC C compiler, and it again not work...

Code:
#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#include<lcd.c>

#define LCD_ENABLE_PIN  PIN_C0                                    ////
#define LCD_RS_PIN      PIN_C1                                    ////
#define LCD_RW_PIN      PIN_C2                                    ////
#define LCD_DATA4       PIN_D4                                    ////
#define LCD_DATA5       PIN_D5                                    ////
#define LCD_DATA6       PIN_D6                                    ////
#define LCD_DATA7       PIN_D7

void main()
{
	set_tris_d(0x00);
	set_tris_c(0x00);
	lcd_init();
 	Delay_ms(100);
	while(1)
	{
		lcd_gotoxy(1,1);
		Delay_ms(1000);
		lcd_putc("\fReady...\n");
	}
}

I am make my own functions, but my main objective to use ccs compiler is to use its USB functions,
But when i a simple LCD is not working how can a more complex protocol device like USB will work..

---------- Post added at 08:34 ---------- Previous post was at 08:29 ----------

hi guyz... new to this forum...

@arunsharma0731 , After following these threads and suggestions i found a modified lcd driver for ccs compiler with a test code to verify it from ccs forum. hope this may help..

Attached Files Attached Files

File Type: zip lcd.zip (59.2 KB)

Hello!! When i use driver file given by you i.e flex_lcd.c it works...

it means there is some fault in lcd.c file available in CCS C for PIC..

Code:
#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#include "flex_lcd.c"

void main()
{
	set_tris_d(0x00);
	set_tris_c(0x00);
	lcd_init();
 	Delay_ms(100);
	while(1)
	{
		lcd_gotoxy(1,1);
		Delay_ms(1000);
		lcd_putc("\fReady...\n");
	}
}


---------- Post added at 08:36 ---------- Previous post was at 08:34 ----------

And i have modified the PIN configuration according to my needs.. in your flex_lcd.c file

Code:
#define LCD_DB4   PIN_D4
#define LCD_DB5   PIN_D5
#define LCD_DB6   PIN_D6
#define LCD_DB7   PIN_D7

#define LCD_E     PIN_C0
#define LCD_RS    PIN_C1
#define LCD_RW    PIN_C2

Now can anyone explain me why the file lcd.c available with CCS PIC C is not working
 

If you can post the contents of the lcd.c file, I'll be glad to examine it.

Also post the contents of flex_lcd.c if possible for a comparison.

There maybe a conflicting or duplicate #define, declaration, definition,etc.

BigDog
 

@arunsharma0731, I got the interest to interface lcd with pic using ccs from the thread you started, I tried all your codes and i tried my own codes with the inbuilt lcd driver file but it just did'nt work after surfing through other forums i figured out that many had this same problem with the driver file, and there was a modified driver file available which worked for me and probably for you too.I couldn't figure out what was wrong in the inbuilt driver file (newbie problem).maybe bigdogguru could explain what is actually the problem with the inbuilt driver file
 

:)

Finally i had solved my problem,,,

Actually this problem occurs because CCS PIC don't follow the C Standards...

Here is the final code that works for me...

One has to include the driver lcd file after pin assignment

like this

Code:
#include<16f877a.h>

#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP


#define LCD_ENABLE_PIN PIN_C0
#define LCD_RS_PIN PIN_C1
#define LCD_RW_PIN PIN_C2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

[B][I]#include <lcd.c>  // Include Here it will work[/I][/B]

void main()
{
	set_tris_d(0x00);
	set_tris_c(0x00);
	lcd_init();
 	Delay_ms(100);
	while(1)
	{
		lcd_gotoxy(1,1);
		Delay_ms(1000);
		lcd_putc("\fReady...\n");
	}
}


---------- Post added at 21:00 ---------- Previous post was at 20:58 ----------

@arunsharma0731, I got the interest to interface lcd with pic using ccs from the thread you started, I tried all your codes and i tried my own codes with the inbuilt lcd driver file but it just did'nt work after surfing through other forums i figured out that many had this same problem with the driver file, and there was a modified driver file available which worked for me and probably for you too.I couldn't figure out what was wrong in the inbuilt driver file (newbie problem).maybe bigdogguru could explain what is actually the problem with the inbuilt driver file

I want to use CCS for USB programming Purpose, but when i see that simple lcd function's are not working then how it is possible that, complex usb functions will work..

But finally solved..
:)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top