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

function problem

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



Joined: 05 Dec 2006
Posts: 3

View user's profile Send private message

function problem
PostPosted: Tue Dec 05, 2006 8:40 am     Reply with quote

Code:
#if defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT
#use delay(clock=4000000 , restart_wdt)
#endif

#include<lcdnewe.c>

#define parametersAd 8
#define multiplier 16

//pin definition
#define MOTOR PIN_C0
#define FAN PIN_C2
#define CIRCULATION PIN_C3
#define DIRECTION PIN_C4
//pin definition
#byte intcon=0xFF2
//time variable
int workTime;
int32 seconds;
int times;
short mode; // surme yada bekleme olması 0 bekleme 1 surme
int timeVariableAdd[2] = {1,2}; // [0] bekleme [1] surme
//time variable

//menu variable
char menuItem[25];
int selection = 0;
int tempVariableAdd[3] = {5,6,7};//0 sirkulasyon,1 durma,2 calışma
char menuIndex[3];
//menu variable

//temp variable
int temp = 0;
int value = 0;
int16 tempSum = 0;
short situation; //0 ust deger altı 1 ust deger ustu
//temp variable

short begining;
short reverse;
int parameters;//situation changed 0,
int k=0;

void readTemp()
{
      restart_wdt();

      value = read_adc();
      if (tempSum == 0)
         tempSum = value;
      else
      {
         if (!(value <tempSum> (tempSum / times + 5)))
            tempSum += value;
         else
            tempSum += (int)(tempSum/(times-1));
      }


      restart_wdt();

      return;
}

void menu(int slc)
{
   restart_wdt();

   switch(slc)
   {
      case 0:
         strcpy(menuItem ,"KAZAN SICAKLIK");
         strcpy(menuIndex ,"C");
         break;
      case 1:
         strcpy(menuItem ,"BEKLEME SURESI");
         strcpy(menuIndex ,"dk");
         break;
      case 2:
         strcpy(menuItem ,"CALISMA SURESI");
         strcpy(menuIndex ,"sn");
         break;
    /*  case 3:
         strcpy(menuItem ,"BEKLEME SURESI 2");
         strcpy(menuIndex ,"dk");
         break;
      case 4:
         strcpy(menuItem ,"CALISMA SURESI 2");
         strcpy(menuIndex ,"sn");
         break;*/
      case 3:
         strcpy(menuItem ,"SIRKULASYON POMPA");
         strcpy(menuIndex ,"C");
         break;
      case 4:
         strcpy(menuItem ,"DURMA SICAKLIGI");
         strcpy(menuIndex ,"C");
         break;
      case 5:
         strcpy(menuItem ,"CALISMA SICAKLIGI");
         strcpy(menuIndex ,"C");
         break;
      case 6:
         strcpy(menuItem ,"GERI CEVIRME");
         strcpy(menuIndex ," ");
         break;
   }

   restart_wdt();
   return;
}

#INT_RB

void menuItems()
{
   int valueb;
   valueb = input_b();
   delay_ms(40);
   if (valueb == input_b())
   {
      valueb = valueb - (valueb%16);
     
      switch(valueb)
      {
         case 0xD0:
            if(selection ==6)
               selection = 0;
            else
               ++selection;
            menu(selection);
            lcd_putc("\f");
            lcd_gotoxy(1,1);
            printf(lcd_putc,menuItem);
            break;
         case 0x70:
            if(selection ==0)
               selection = 6;
            else
               --selection;
            menu(selection);
            lcd_putc("\f");
            lcd_gotoxy(1,1);
            printf(lcd_putc,menuItem);
            break;
      }

   }
   return;

}

void main()
{
   
   char i;
   
   set_tris_b(0b11110000);
   selection = 0;
   setup_adc_ports( RA0_ANALOG_RA3_RA2_REF);
   setup_adc( ADC_CLOCK_INTERNAL );
   set_adc_channel( 0 );

   delay_ms(100);
   lcd_init();
   lcd_gotoxy(3,2);
   printf(lcd_putc,"deneme");
   delay_ms(1000);
   
   intcon = 0b11001000;
   
   
   delay_ms(1000);
   readTemp();
   
   menu(selection);
   lcd_putc("\f");
   lcd_gotoxy(1,1);
   printf(lcd_putc,menuItem);
   lcd_gotoxy(3,2);
   printf(lcd_putc," %u  ",value);
   lcd_gotoxy(9,2);
   printf(lcd_putc,menuIndex);
   while(1)
   {
   } 
   
}



I use this code to change the menu items on the lcd but when add a code that calls the function menu it begins to reset itself what can be the problem
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Dec 05, 2006 1:40 pm     Reply with quote

Check the restart-cause() function to see why the PIC reset.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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