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

gsm kbhit problem

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



Joined: 27 Feb 2006
Posts: 20

View user's profile Send private message

gsm kbhit problem
PostPosted: Thu Apr 13, 2006 10:28 am     Reply with quote

i have an interface built to connect a 16f74 to a gsm sim card, and when i try to reset the card i can see the information being produced from the gsm on an oscilloscope and due to this i know that the pic can see the information, which is reaching pin c7.But it is not transferring the information to the PC

the following is the code i am using to try and read the information coming back from the gsm sim card for the reset command, its a bit long but i hope someone sees something obviously wrong.

also when the reset command is sent from the hyperterminal, the pic stops responding to other commands such as the test to see if its transmitting to the PC.

this is the code
Code:

#include <16F74.h>
#device adc=8
#fuses NOWDT,XT, NOPUT, NOPROTECT, BROWNOUT
#use delay(clock=3620000)
#use rs232(baud=9600, parity=n, bits=8, xmit=pin_a2, rcv=pin_a4,ERRORS, stream=PC)//PC
#use rs232(baud=9600, parity=n, bits=8, xmit=pin_c6, rcv=pin_c7,ERRORS, stream=GSM)//GSM
int timeout;
char answer;
long testtimer;
char responce[70];
int counter;


void InitialContacts()
{
output_high(PIN_B3);   //Disables clock
output_high(PIN_B7);   //Puts direction in receive mode
output_low(PIN_B2);      //Disables VCC
output_low(PIN_B1);      //Puts reset in low state
output_low(PIN_B0);      //puts VPP in low state

}

void SetUpContacts()
{
output_low(PIN_B1);      //puts reset in low state
delay_us(10);         //small delay
output_high(PIN_B2);   //puts Vcc high
delay_us(10);
output_high(PIN_B7);   //puts I/O in receive mode
delay_us(10);
output_high(PIN_B0);   //raises Vpp to high voltage to activate sim card
delay_us(10);
output_float(PIN_B0);   //raises Vpp to idle
delay_us(10);
output_low(PIN_B3);      //applies clock to card
output_float(PIN_B4);
output_float(PIN_B5);
output_float(PIN_B6);      
}

void DeactivateContacts()
{
output_low(PIN_B1);      //puts reset in low state
delay_us(10);         //small delay
output_high(PIN_B3);   //denies clock to card
delay_us(10);
output_low(PIN_B0);      //disables vpp

delay_us(10);
output_high(PIN_B7);   //puts I/O in receive mode
delay_us(10);
output_low(PIN_B2);      //puts Vcc low
}

void main()
{
   InitialContacts();
   start:
     timeout=0;
   testtimer=0;
      while ((!kbhit(PC)&&(++timeout<500)))   // 5ms
      {
         delay_us(10);
      }

         if(kbhit(PC))
      {
      
         answer=getch(PC);
         if (answer=='a')
         {
            fprintf(PC,"PICisTALKING");
            goto start;
         }
         if (answer=='c')
         {
            SetUpContacts();
            goto start;
         }
         if (answer=='f')
         {
            output_high(PIN_B0);
            output_high(PIN_B1);
            output_high(PIN_B2);
            output_high(PIN_B3);
            output_high(PIN_B4);
            output_high(PIN_B5);
            output_high(PIN_B6);
            output_high(PIN_B7);
            goto start;
         }
         if (answer=='r')
         {
            output_high(PIN_B1); //puts rst in high state
            testtimer=0;
            while ((!kbhit(gsm)&&(++timeout<500)))
            {
               delay_us(10);      
            }
            if(kbhit(GSM))
            {
               int i;
               timeout=0;

               while(++timeout<500)
               {
                  ++counter;
                  responce[counter]=getch(GSM);
               }
         
               fprintf(PC,"count= ");
               fprintf(PC,counter);
               fprintf(PC,"D= ");
               for (i=0;i<=counter;i++)
               {
                  fprintf(PC,responce[i]);
               }
               fprintf(PC,"H= ");
               for (i=0;i<=counter;i++)
               {
                  fprintf(PC,"%X",responce[i]);
               }
               goto start;
            
            }
            else
            {
            fprintf(PC,"no kbhit GSM");
            goto start;
            }
         }
      }
      else
      {
         putc('N');
         putc('O');
         goto start;
      }
   
}
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