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 support@ccsinfo.com

a little bit help ı couldn't work
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

a little bit help ı couldn't work
PostPosted: Mon Apr 07, 2014 1:14 pm     Reply with quote

why isn't working?

Code:
#include <18f4550.h>     // Kullanılacak denetleyicinin başlık dosyası tanıtılıyor.


// Denetleyici konfigürasyon ayarları
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD

#use delay (clock=20M) // Gecikme fonksiyonu için kullanılacak osilatör frekansı belirtiliyor.

#define LCD_DATA_PORT getenv("SFR:PORTD")
#include <lcd.c>
     #define LCD_ENABLE_PIN  PIN_B5                                    ////
     #define LCD_RS_PIN      PIN_C0                                    ////
     #define LCD_RW_PIN      PIN_B4                                    ////
     #define LCD_DATA4       PIN_D4                                    ////
     #define LCD_DATA5       PIN_D5                                    ////
     #define LCD_DATA6       PIN_D6                                    ////
     #define LCD_DATA7       PIN_D7     // LCD B portuna bağlı

void main ( )
{
   setup_psp(PSP_DISABLED);        // PSP birimi devre dışı
   setup_timer_1(T1_DISABLED);     // T1 zamanlayıcısı devre dışı
   setup_timer_2(T2_DISABLED,0,1); // T2 zamanlayıcısı devre dışı
   setup_CCP1(CCP_OFF);            // CCP1 birimi devre dışı
   setup_CCP2(CCP_OFF);            // CCP2 birimi devre dışı

   
    lcd_init();  // LCD hazır hale getiriliyor
      while(1)   // sonsuz döngü
   {
      lcd_gotoxy(10,2); // İmleç 1. satır 10.sütunda
      printf(lcd_putc,"Hi baby="); // LCD'ye yazı yazdırılıyor
      delay_ms(100); // 100 msn gecikme
   }
}
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Apr 07, 2014 1:41 pm     Reply with quote

Two things right off the top - typically you need to wait a bit before calling lcd_init() (those things are slow to wake up - 500ms or so is a good start). Second, you are updating the display at a 10 hz rate - most LCD displays (and your eyes) can't handle that. You should not update a LCD more than 2 or 3 times / second.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 07, 2014 2:16 pm     Reply with quote

Delete this line:
Quote:
#define LCD_DATA_PORT getenv("SFR:PORTD")


Then read this thread about putting the #define statements for the pins
above the #include line for lcd.c:
http://www.ccsinfo.com/forum/viewtopic.php?t=47663
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Mon Apr 07, 2014 10:45 pm     Reply with quote

I'm really appreciative but still not working.

Code:
#include <18f4550.h>     // Kullanılacak denetleyicinin başlık dosyası tanıtılıyor.

// Denetleyici konfigürasyon ayarları
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD

#use delay (clock=20M) // Gecikme fonksiyonu için kullanılacak osilatör frekansı belirtiliyor.

     #define LCD_ENABLE_PIN  PIN_B5                                    ////
     #define LCD_RS_PIN      PIN_C0                                    ////
     #define LCD_RW_PIN      PIN_B4                                    ////
     #define LCD_DATA4       PIN_D4                                    ////
     #define LCD_DATA5       PIN_D5                                    ////
     #define LCD_DATA6       PIN_D6                                    ////
     #define LCD_DATA7       PIN_D7     // LCD B portuna bağlı
#include <lcd.c>

void main ( )
{
   setup_psp(PSP_DISABLED);        // PSP birimi devre dışı
   setup_timer_1(T1_DISABLED);     // T1 zamanlayıcısı devre dışı
   setup_timer_2(T2_DISABLED,0,1); // T2 zamanlayıcısı devre dışı
   setup_CCP1(CCP_OFF);            // CCP1 birimi devre dışı
   setup_CCP2(CCP_OFF);            // CCP2 birimi devre dışı

   set_tris_d(0x00);
   set_tris_c(0x00);
   set_tris_b(0x00);
   lcd_init();
   delay_ms(1000);// LCD hazır hale getiriliyor
   while(1)   // sonsuz döngü
   {
      lcd_gotoxy(1,1); // İmleç 1. satır 10.sütunda
      delay_ms(1000); // 100 msn gecikme
      printf(lcd_putc,"Hi baby="); // LCD'ye yazı yazdırılıyor
      delay_ms(1000);
   }
}
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Mon Apr 07, 2014 11:05 pm     Reply with quote

You have not really told us what the problem is.
Is the PIC working at correct speed (Blink a led at 1 Hz to check)?
Has the screen got black(or whatever colour screen you have) boxes, or is it blank?

Also, get rid of the following. It should not make a difference, but you don't need it unless you are using FAST_IO.
Code:

set_tris_d(0x00);
set_tris_c(0x00);
set_tris_b(0x00);


Then, put another delay_ms(1000) before the lcd_init() line. You can play around with this later once you know it works. Some displays like a delay before init, some like it after and some like it both ways...
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 12:36 am     Reply with quote

I'm trying to get any figure on the screen. but code not working, anyway I will add delay_ms(1000); before LCD_init(); hope work this time thanks.
Code:

#include <18f4550.h>
 #fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD

 #use delay (clock=20M)

      #define LCD_ENABLE_PIN  PIN_B5                               
      #define LCD_RS_PIN      PIN_C0                                   
      #define LCD_RW_PIN      PIN_B4                                 
      #define LCD_DATA4       PIN_D4                                   
      #define LCD_DATA5       PIN_D5                                   
      #define LCD_DATA6       PIN_D6                                   
      #define LCD_DATA7       PIN_D7   

#include <lcd.c>

 void main ( )
 {
    setup_psp(PSP_DISABLED);        // PSP birimi devre dışı
   setup_timer_1(T1_DISABLED);     // T1 zamanlayıcısı devre dışı
   setup_timer_2(T2_DISABLED,0,1); // T2 zamanlayıcısı devre dışı
   setup_CCP1(CCP_OFF);            // CCP1 birimi devre dışı
   setup_CCP2(CCP_OFF);            // CCP2 birimi devre dışı


    delay_ms(1000);
    lcd_init();
    delay_ms(1000);

    while(1)   
    {
       lcd_gotoxy(1,1);
       delay_ms(1000);
       printf(lcd_putc,"Hi baby="); 
       delay_ms(1000);
    }
 }
Ttelmah



Joined: 11 Mar 2010
Posts: 19384

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 1:05 am     Reply with quote

Seriously, 'step back'.

Have you actually verified your processor is running at all?. At the correct speed?.

The _first_ thing you will see advised here for a lot of threads (and add this one to the list), is to perform the simple 'flash an LED' test. LED wired onto one pin (with a suitable current limiting resistor), and a minimum program to flash this at a regular interval like 10 seconds.
This needs to work, and be flashing at the right speed _before_ you make any attempt to go further in programming.
It verifies:
1) Power is correct.
2) Reset circuit is correct.
3) Clock oscillator is running.
4) Clock is running at the right speed (time the flashes).
5) That you are programming the chip correctly.
6) That the chip itself is working.

Only once this is working right, progress to trying to do anything more complex.
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 1:15 am     Reply with quote

you 're master, ı will do what you ever you said

1) Power is correct. >>>>>yes correct
2) Reset circuit is correct. >>>>>yes
3) Clock oscillator is running. >>>>>measured 20mhz
4) Clock is running at the right speed (time the flashes). >>>>ı dont under stand what is mean
5) That you are programming the chip correctly. >>>> ı will check again
6) That the chip itself is working. >>>> ı will check
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 1:53 am     Reply with quote

idris wrote:
.........
.........
4) Clock is running at the right speed (time the flashes). >>>>ı dont under stand what is mean
........
........

You were told to write code to flash an LED at a fixed rate.
Time the flashes with your watch!
Do not proceed beyond this point until it works correctly.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9178
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 6:05 am     Reply with quote

Normally the first program you code for a PIC is the '1Hz flashing LED' program.

Simple hardware...just an LED and resistor on an I/O pin,usually one you're not going to use later....

Simple software....

main()
do
output_high(LED);
delay_ms(500);
output_low(LED);
delay_ms(500);
while(true);


probably a typr or two...
the idea is to turn an LED on/off at a known rate, 1 HZ is 'nice'.

this program will confirm 'fuses' are set correctly,hardware is OK, etc.

also I'd use fuse PUT instead of NOPUT.
The Power Up Timer allows the PIC to startup more reliably.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19384

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 9:35 am     Reply with quote

Yes.

You missed the point about my question. Testing with a meter/scope, does not prove that the PIC is getting the right voltage in the right place, or that the oscillator actually runs (when the scope is not there), and that the chip is running at the right speed. The simple flash an LED test, does.

There are two things I suspect.
First, that you are actually running at 5MHz, not 20MHz. You don't have a CPUDIV1 fuse, and I think that the default for this is CPUDIV4. So with a 20MHz crystal, the chip will be running at 5MHz. The LED test would have found this at once.
The second is that the chip may not be starting at all. Is MCLR pulled high?. Again the default is for this to be enabled, since you haven't got it turned off, and the chip won't run unless the pin is pulled up.

Then as a separate comment, temtronic has pointed out NOPUT. The power up timer, is _recommended_ if you are running with a crystal. Should only be disabled, if you are using the RC oscillator, or two speed startup (starting on the RC, and then switching once the main oscillator is running).
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 10:40 am     Reply with quote

no ı found problem but the problem is so holy ı guess computer thought like holly any way

ı'm gonna break these computer there is no hope for me, ı can not work really easy code, pls someone help me how ı define that holly "glcd_pixel" because of if ı define these word, problem solved anyway ı will break these piece of junk. thanks

error: undefined identifier --glcd_pixel

Code:
#include <asd.h> // ossicilator is true

#include <graphics.c>
void main()
{
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);


   while(TRUE)
   {
   glcd_pixel(0, 0, 1);
      glcd_line(0, 10, 10, 20, 1);
   }
}




---------------------------------------------------------------------------------
Code:

/////////////////////////////////////////////////////////////////////////
////                          graphics.c                             ////
////                                                                 ////
////   This file contains functions to draw lines, rectangles, bars, ////
////   circles and text to a display. A function which draws a       ////
////   single pixel must be defined before calling the functions in  ////
////   this file. Call it glcd_pixel(x, y, color) where x is the     ////
////   horizontal coordinate, y is the vertical coordinate, and      ////
////   color is 1 bit to turn the pixel on or off.                   ////




++++++++++++++++++++++++++++
CCS driver code removed, per forum rule #10.

10. Don't post the CCS example code or drivers.
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

- Forum Moderator
++++++++++++++++++++++++++++


Last edited by idris on Tue Apr 08, 2014 11:56 am; edited 1 time in total
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 11:51 am     Reply with quote

Code:
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996, 2004 Custom Computer Services        ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////
sigh.... Rolling Eyes

Delete this part of your post, you are not allowed to reproduce it on the internet!
Besides, we all do own the compiler and already have this file. Removing it will make your post smaller and easier to read.
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 12:17 pm     Reply with quote

sorry for that admin

I will check myself and I add a led pin_b7
Code:

output_high(pin_b7);
delay_ms(500);
output_low(pin_b7);
delay_ms(500);

It's working but lcd problem go on.
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Tue Apr 08, 2014 12:22 pm     Reply with quote

led is working, complier is working but there is no figure on screen

Code:
#include <asd.h>

#define LCD_ENABLE_PIN  PIN_B5                                 
#define LCD_RS_PIN      PIN_B6                                   
#define LCD_RW_PIN      PIN_B4                                   
#define LCD_DATA4       PIN_D4                                   
#define LCD_DATA5       PIN_D5                               
#define LCD_DATA6       PIN_D6                                   
#define LCD_DATA7       PIN_D7
#include <lcd.c>
#include <lcd.c>
char asd[]= "asdasd";
void main()
{
setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(VREF_LOW|-2);

   set_tris_b(0x00);
   
   output_b(0x00);
   
   basla:
   
   output_high(pin_b7);
   delay_ms(500);
   output_low(pin_b7);
   delay_ms(500);
   goto basla;
 


lcd_init();
delay_ms(100);
   while(TRUE)
   {
     lcd_putc("/fasdasdasdasd");
     delay_ms(100);
   }

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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