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

Sony Ericson GM29

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







Sony Ericson GM29
PostPosted: Mon Jan 05, 2009 4:58 am     Reply with quote

Hi im trying to design a signal tester, and I seem to be getting good results with any other modem.

This source code works perfectly with a wavecom FASTRACK modem.
Code:

#if defined(__PCM__)
#include <16F876.h>
#device adc=8
#fuses XT,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NODEBUG
#define LOWTOHIGH TRUE
#define HIGHTOLOW FALSE
#use delay(clock =4032000,XTAL)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,BRGH1OK)
#define BUFFER_SIZE 96
char buffer[BUFFER_SIZE];
int buffer_used=0;
#int_rda
void serial_isr()                 //A serial intterupt which stores the each character in a buffer/array for later use.
   {
   buffer[buffer_used]=getc();   // Stores the size of the buffer
   output_low(pin_a4);           //Sync LED shows that the device have recieved a response from the modem
   if (buffer_used == 94)        //If there was an error, which Led to the device and the modem not communicating
      buffer_used =0;            //the buffer would not overflow, the effect is the device not freezing and enables it to retry.
   buffer_used++;                //Increasing the buffer with each succesfull character recieved
   }
#include <stdlib.h>
#include <stdio.h>
int high=8,low=8,Nsignal_strength=88;                 //Initializing the device with a signal strength which does not exist
byte signal_check=0,reset_modem=0,output_signal=0;    //Initializing A/D convertes *note output_signal only for debugging issues.
void output_buffer();
//void readbuffer();
void flash();
void reset();
void determine_strength();
void main()
{
   enable_interrupts(global);
   enable_interrupts(int_rda);
  setup_adc_ports(AN0_AN1_AN3);
  setup_adc(ADC_CLOCK_INTERNAL);
   
  delay_ms(100);output_low(pin_b0);delay_ms(100);output_high(pin_b0);
   delay_ms(100);output_low(pin_b1);delay_ms(100);output_high(pin_b1);
   delay_ms(100);output_low(pin_b2);delay_ms(100);output_high(pin_b2);
   delay_ms(100);output_low(pin_b3);delay_ms(100);output_high(pin_b3);
   delay_ms(100);output_low(pin_b4);delay_ms(100);output_high(pin_b4);//Start up as well as all LEDS must work
   delay_ms(100);output_low(pin_b5);delay_ms(100);output_high(pin_b5);
   delay_ms(100);output_low(pin_b6);delay_ms(100);output_high(pin_b6);
   delay_ms(100);output_low(pin_b7);delay_ms(100);output_high(pin_b7);

   delay_ms(100);output_low(pin_b7);delay_ms(100);output_high(pin_b7);
   delay_ms(100);output_low(pin_b6);delay_ms(100);output_high(pin_b6);
   delay_ms(100);output_low(pin_b5);delay_ms(100);output_high(pin_b5);
   delay_ms(100);output_low(pin_b4);delay_ms(100);output_high(pin_b4);
   delay_ms(100);output_low(pin_b3);delay_ms(100);output_high(pin_b3);//Start up as well as all LEDS must work
   delay_ms(100);output_low(pin_b2);delay_ms(100);output_high(pin_b2);
   delay_ms(100);output_low(pin_b1);delay_ms(100);output_high(pin_b1);
   delay_ms(100);output_low(pin_b0);delay_ms(100);output_high(pin_b0);


   
   while (1)
   {
   set_adc_channel( 0 );delay_us(200);                               //Enabling the A/D
   signal_check=read_adc();delay_us(200);
   set_adc_channel( 1 );delay_us(200);
   reset_modem=read_adc();delay_us(200);   
  // set_adc_channel( 3 );delay_us(200);
  // output_signal=read_adc();delay_us(200);
      if (signal_check > 30)                                         //If singal check pressed let status LED flash
         {
            output_low(pin_a5);             
            delay_ms(100);
            output_high(pin_a5);
            delay_ms(100);
            output_low(pin_a5);
            delay_ms(100);
            output_high(pin_a5);
            putc('A');delay_ms(1);putc('T');delay_ms(1);putc('+');delay_ms(1);putc('C');delay_ms(1);putc('S');delay_ms(1);putc('Q');delay_ms(1);putc(0x0D);putc(0x0A);
            delay_ms(1);                                             //Sends instruction twice to modem for extra rebiality
            putc('A');delay_ms(1);putc('T');delay_ms(1);putc('+');delay_ms(1);putc('C');delay_ms(1);putc('S');delay_ms(1);putc('Q');delay_ms(1);putc(0x0A);putc(0x0D);           
            determine_strength();                                    //Calls the function which determines the signal strength
            output_high(pin_a5);
           
         }
      if (reset_modem >5)                                            //If reset modem pressed let status LED blinb
         {
            output_low(pin_a5);
            putc('A');delay_ms(1);putc('T');delay_ms(1);putc('Z');delay_ms(1);putc(0x0D);putc(0x0A);
            delay_ms(1);
            putc('A');delay_ms(1);putc('T');delay_ms(1);putc('Z');delay_ms(1);putc(0x0A);putc(0x0D);
            delay_ms(1);
           // output_buffer();                                                //Calls the function to reset the modem
            reset();
            delay_ms(100);
            output_high(pin_a5);
         }
    //   if (output_signal > 5)                                      //debuggin purposes only
    //   output_buffer();
     
//Displaying signal strength
if ((Nsignal_strength <=31)&& (Nsignal_strength >28)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2); output_low(pin_b3); output_low(pin_b4); output_low(pin_b5); output_low(pin_b6); output_low(pin_b7);}
if ((Nsignal_strength <=28)&& (Nsignal_strength >24)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2); output_low(pin_b3); output_low(pin_b4); output_low(pin_b5); output_low(pin_b6);output_high(pin_b7);}
if ((Nsignal_strength <=24)&& (Nsignal_strength >21)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2); output_low(pin_b3); output_low(pin_b4); output_low(pin_b5);output_high(pin_b6);output_high(pin_b7);}
if ((Nsignal_strength <=21)&& (Nsignal_strength >17)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2); output_low(pin_b3); output_low(pin_b4);output_high(pin_b5);output_high(pin_b6);output_high(pin_b7);}
if ((Nsignal_strength <=17)&& (Nsignal_strength >14)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2); output_low(pin_b3);output_high(pin_b4);output_high(pin_b5);output_high(pin_b6);output_high(pin_b7);}
if ((Nsignal_strength <=14)&& (Nsignal_strength >10)){ output_low(pin_b0); output_low(pin_b1); output_low(pin_b2);output_high(pin_b3);output_high(pin_b4);output_high(pin_b5);output_high(pin_b6);output_high(pin_b7);}
if ((Nsignal_strength <=10)&& (Nsignal_strength >7 )){ output_low(pin_b0); output_low(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);}
if ((Nsignal_strength <=7) && (Nsignal_strength >3 )){ output_low(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);}
if ((Nsignal_strength <=3) && (Nsignal_strength >=0)){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);}

//No signal
if ((Nsignal_strength ==99)){flash();}
  }
 
}

void flash()
{
int j;
for ( j=0;j<=3;j++)
{
   delay_ms(100);
   output_low(pin_b0); //lets the LED's flash for indication purposes
   output_low(pin_b1);
   output_low(pin_b2);
   output_low(pin_b3);
   output_low(pin_b4);
   output_low(pin_b5);
   output_low(pin_b6);
   output_low(pin_b7);
   delay_ms(100);
   output_high(pin_b0); //lets the LED's flash for indication purposes
   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);
}
}
void output_buffer()                   // debugging purposes only to check what is stored in the buffer
{
int size;
 printf("Buffer =>\n");
  for (size=0;size<=buffer_used;size++)
   putc(buffer[size]);
}
void reset()
{
int i=0;
boolean flag;
  While ((flag==true) && (i <= buffer_used))             //Check untill first consective OK or untill buffer completely checked
     {
       if (buffer[i]== 'O')                              //As soon as device recieves the first OK its stops searching
         if ((buffer[i+1] == 'K'))                       //Flashes LED's to indicate device (buffer) and modems been reset.
            {flag=true;flash();}
            i++;
     }
    buffer_used=0;                                       //resets buffer
    Nsignal_strength=0;                                  //resets signal strength
}
void determine_strength()
{                                                                       // PIC does not to appear to have ability to perform the function itoa
int i=0;                                                                // own sourcecode was supplied
boolean flag=false,single=false,number=false;
  While ((flag==false) && (i <= buffer_used))                           //Checks the whole buffer or until a number is found
     {
         switch (buffer[i])
         {
          case '0':{high=0;number=true;break;}                          //When the number 0..3 indicate that it is a number
          case '1':{high=1;number=true;break;}
          case '2':{high=2;number=true;break;}
          case '3':{high=3;number=true;output_low(pin_b5);break;}       //if number is 3 put LED 5 on debugging purpose only
          case '4':{high=4;number=true;flag=true;single=true;break;}    //when number 4..9 indicate it is anumber and a single digit
          case '5':{high=5;number=true;flag=true;single=true;break;}
          case '6':{high=6;number=true;flag=true;single=true;break;}
          case '7':{high=7;number=true;flag=true;single=true;break;}
          case '8':{high=8;number=true;flag=true;single=true;break;}
          case '9':{high=9;number=true;flag=true;single=true;break;}
         }
   if (number==true){                                                   //checks if the next character is a number
       if (buffer[i+1]=='0'){low=0;flag=true;}                          //if it is a number, then it is dubble digit
        if (buffer[i+1]=='1'){low=1;flag=true;output_low(pin_b6);}      //if second digit is a 1 output LED 6 debug purposes only
         if (buffer[i+1]=='2'){low=2;flag=true;}
          if (buffer[i+1]=='3'){low=3;flag=true;}
           if (buffer[i+1]=='4'){low=4;flag=true;}
            if (buffer[i+1]=='5'){low=5;flag=true;}
             if (buffer[i+1]=='6'){low=6;flag=true;}
              if (buffer[i+1]=='7'){low=7;flag=true;}
               if (buffer[i+1]=='8'){low=8;flag=true;}
                if (buffer[i+1]=='9'){low=9;flag=true;}
    if(buffer[i+1]==','){single=true;}                                    //if the next character is , it is a single number this is for numbers 0..3 only
       }
           
            i++;
     }
         if (single==false)                                               //If it is not a single number calculate the signal strength with both numbers
            {Nsignal_strength=high*10 + low;}           
         if (single==true)                                                //If it is a single number determine signal strength with first digit
            {Nsignal_strength=high;}                                     
             output_low(pin_b7);                                          //Output LED 7 and 6 if procedure finished
             output_low(pin_b6);                                          //*note first time modems misses first character so LED 7 &6 will always show first time
             buffer_used=0;                                               //resets buffer
}

I have tried printf, it works also with the other modems but with the Sony ericson gm29 I don't even get an echo interrupt (when a serial interrupt occurs it puts a LED on). Both the modems works with normal hyperterminal so does anyone know if the gm29 works different or am I doing something wrong, please help
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