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

Hypertermial Showing Garbage Despite Correct Baud Rate
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mka879



Joined: 30 Oct 2015
Posts: 34

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 6:27 am     Reply with quote

ezflyr wrote:
Hi,

Don't fool yourself, delays inside interrupt handlers are a 'significant factor' in virtually *any* circumstance! Just don't do it!

To answer your specific question, the Carriage Return (or Enter key) can be sent with '\r'.


Thank you, I have modified the code.

Sim900 has a feature of echo back characters which are sent. I can read the characters I sent to the module correctly however when I send AT it does not respond with OK. What might be wrong? The code is as below
Code:
#include <gsm test.h>
#include<string.h>
#use rs232(baud=9600,xmit=PIN_c6,rcv=PIN_c7,PARITY=N,BITS=8,STOP=1)
char flag[20];
int counter = 0;
#int_rda
void isr_rda(void)
{
   
   if (counter == 0)
      output_bit(pin_b4,1);
   if (counter == 1)
      output_bit(pin_b5,1);
   if (counter == 2)
      output_bit(pin_b3,1);
   if (counter == 3)
      output_bit(pin_b2,1);
   if (counter == 4)
      output_bit(pin_b1,1);
   flag[counter] = getc();
   clear_interrupt(int_rda);
   counter++;
}

void main()
{
   //time for GSM Modem to initialize and register on the network
   output_bit(pin_b7,1);
   delay_ms(1000);
   output_bit(pin_b7,0);
   delay_ms(1000);
   enable_interrupts(global);
   enable_interrupts(int_rda); 
   char par[5] = {'O','K','\r'};
   char par1[2];
   flag = "no";
       
      while(strcmp(flag,par))
      {   
         delay_ms(4000);
         printf("AT\r");
         output_bit(pin_b7,1);//flag if sending AT and OK is not received
         delay_ms(1000);
         output_bit(pin_b7,0);
         delay_ms(1000);         
      }
      output_bit(pin_b7,1);//flag if OK is received
   
}


When I replace AT\r with AT and check if it is echoed back by sim900 b4 and b5 LEDs become active as indicated by ISR and b7 becomes high indicating AT is received. Whenever AT+enter is sent to the module it responds with OK but if only AT is typed without enter key the module echoes back.
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 8:43 am     Reply with quote

The delays, very much do affect the current situation.

In TeraTerm, typing replies yourself, you take _time_ to reply. The modem does not. It sends it's 'OK', almost instantaneously after receiving the command. _Very_ different.


Last edited by Ttelmah on Thu Nov 05, 2015 2:41 am; edited 1 time in total
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 9:51 am     Reply with quote

Hi,

A couple of things:

1. You need to add the 'Errors' keyword to your #use rs232 directive. This will allow the PIC UART to recover from an overflow without locking up!

2. You can get rid of the 'clear_interrupt(int_rda)' statement inside the ISR. This is already handled by the compiler, and in rare conditions can cause an issue if you do it as well.

There is a complete GSM project in the Code Library provided by forum user 'Gabriel'. I recommend that you study this code to see how he handles the exchange of data between the PIC and the GSM modem.
_________________
John

If it's worth doing, it's worth doing in real hardware!
mka879



Joined: 30 Oct 2015
Posts: 34

View user's profile Send private message

PostPosted: Tue Nov 17, 2015 1:50 am     Reply with quote

Thank you everybody especially ezflyr and Ttelmah. ezflyr suggestion of including ERRORS in #use 232 proved to be a life saver. I am so happy after getting the GSM module working correctly.
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 Previous  1, 2
Page 2 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