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

strange problem with out data parallel on port

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



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

strange problem with out data parallel on port
PostPosted: Thu Mar 29, 2007 5:27 pm     Reply with quote

hi all

i have strange problem with port D.its never out the value and still dead!!!
here is my code:

Code:


#include <16f877a.h>
#include "lcd_kbd1.c"
#include <string.h>
#fuses XT,NOWDT,NOLVP
#use delay(clock=4000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#byte tris_d =0x00         




static char RX[45] ,NUM[10],CMD[10];
static char S1[5],S2[5],S3[5],S4[5],S5[5],S6[5],S7[5],S8[5],S9[5],C[5];
static int1 flag,k;
static int8 i,n,f,t;
static int8 rank1,rank2,rank3,rank4;
static int8 M1,M2,M3,M4;



#int_rda
void serial_isr()  {

RX[i++]=getch();

flag=1;
k=0;
}


void main()   {
   flag=0;
   k=0;
   M1=0X01;
   M2=0X02;
   M3=0X03;
   M4=0X04;
   

   strcpy(S1,"*");
   strcpy(S2,"$");
   strcpy(S3,"&");
   strcpy(S4,"#");

   strcpy(S5,"1");
   strcpy(S6,"2");
   strcpy(S7,"3");
   strcpy(S8,"4");
   strcpy(S9,"OK");
   strcpy(C,"0x1a");

      LCD_Init ( );

   enable_interrupts(GLOBAL);
   enable_interrupts(INT_RDA);
   LCD_PutCmd ( CLEAR_DISP );



while(1)
   {



    if((flag==0) && (k==0)) {
   output_d(0x00);
     LCD_PutCmd ( CLEAR_DISP );

   LCD_SetPosition ( LINE_16_1);
   printf(LCD_PutChar,"NUM:");
   LCD_SetPosition ( LINE_16_2);
   printf(LCD_PutChar,"%s",NUM);

   delay_ms(1000);

  LCD_PutCmd ( CLEAR_DISP );

   LCD_SetPosition ( LINE_16_1);
   printf(LCD_PutChar,"CMD:");
   LCD_SetPosition ( LINE_16_2);
   printf(LCD_PutChar,"%s",CMD);

  delay_ms(2000);

   }

   if(flag==1) {
////////////////////////GET NUM//////////////////////////
respons:
      n=0;                     
      rank1=strcspn(RX, S1);     

      rank2=strcspn(RX, S2);     


      for(i=(rank1+1);i<(rank2);i++) {
      NUM[n]=RX[i];
      n++;
         }//for
/////////////////////GET CMD/////////////////////////////////

      f=0;                       
      rank3=strcspn(RX, S3);   

      rank4=strcspn(RX, S4);   


      for(i=(rank3+1);i<(rank4);i++) {
      CMD[f]=RX[i];
      f++;
         }//for





       if(!strcmp(NUM, S6)) {
      goto next; 
      }


      else
        if(!strcmp(NUM, S5)) {
      goto end;
      }

   
next:



       if(!strcmp(CMD, S6)) {
       output_d(M1);
     delay_ms(3000);

         flag=0;
         k=1;
         while(flag==0)
         {

         }//wait response
         goto respons;
         //wait response
      }

      else
        if(!strcmp(CMD, S7)) {
        output_d(M2);
         delay_ms(3000);


          flag=0;
          k=1;
         while(flag==0)
         {

         }//wait response
         goto respons;
         //wait response

         }
      else
        if(!strcmp(CMD, S8)) {
        output_d(M3);
       delay_ms(3000);
 
         k=1;
         flag=0;
         while(flag==0)
         {

         }//wait response
         goto respons;
         //wait response


            }
     else
        if(!strcmp(CMD, S9)) {
          output_d(M4);
       delay_ms(3000);


         k=1;
         flag=0;
         while(flag==0)
         {

         }//wait response
         goto respons;
         //wait response

          }










end:
   n=0;
   rank1=0;
   rank2=strlen(RX);
   for(i=(rank1+1);i<(rank2);i++) {
   RX[n]=0;
   n++;
      }//clear
     output_d(0x00);
    delay_ms(3000);
    k=0;
    flag=0;
    i=0;


       }//if

   }//while
}//MAIN






every thin work fine,receive string ,analyze, display,except out data on port d!!!i try to chang to port b,or a,and same problem face me.

then i try to make a subroutine like this:

Code:


void set_port( int );


void set_port(int M)
{
   set_tris_d(0x00);
   
   output_d(M);
   delay_ms(3000);

}


instead of out data directly,,,but nothing change,,help plz
not:my ccs version is 3.249

thank you all
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 29, 2007 5:47 pm     Reply with quote

Try the test program shown below. It should toggle Port D between
0x00 and 0xFF. This will tell you if your compiler and your hardware
is working OK.
Code:

#include <16F877A.H>
#fuses XT, NOWDT, NOLVP
#use delay(clock=4000000) 

//==========================
void main()
{

while(1)
  {
   output_d(0xFF);
   delay_ms(500);

   output_d(0x00);
   delay_ms(500);
  }

}


Also, you have this line in your program. You're not using it, but I
wonder if you have tried to use it ? It's completely wrong.
Quote:
#byte tris_d =0x00

The #byte directive is used to tell the compiler the address of
the register. It's not used to set the value. The address of the TRISD
register is 0x88. You can find it in the 16F877A data sheet.
The line should look like this:
Code:
#byte tris_d = 0x88
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 11:58 am     Reply with quote

hi pcm
i try it and it work perfectly both on simulation and on hardware>

i try to use output_high(pin_d0) and output_low(pin_d0) but still not work
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 1:44 pm     Reply with quote

Quote:
I try to use output_high(pin_d0) and output_low(pin_d0) but still not work

Make a short test program (similar to the one I did above) that tests
those two lines of code. If it doesn't work, then post it and I'll test it.
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 3:31 pm     Reply with quote

thank you Cool
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