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

TC35 and PIC18F25K20 UART problem
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
Dempsey



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Tue Oct 06, 2015 1:46 pm     Reply with quote

Sorry I didn't say that I have got two different GSM modules. I found a PDF http://www.sainsmart.com/zen/documents/20-012-100/GSMV1.pdf.
ezflyr



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

View user's profile Send private message

PostPosted: Tue Oct 06, 2015 2:31 pm     Reply with quote

Hi,

Remove any jumpers attached to 'JP2'. This will isolate the MAX232 from the TC35 Tx/Rx pins. Connect your module to the PIC as follows:

TC35 Module JP6 Pin 1 (RXD0) should connect to the Tx pin of your PIC.
TC35 Module JP6 Pin 2 (TXD0) should connect to the Rx pin of your PIC.

Obviously, there also needs to be a 'common GND' connection between your TC35 module, and the PIC PCB.
_________________
John

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



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 5:00 am     Reply with quote

Hi,
I removed all jumpers of the JP2 and connect the GSM module to my PIC. When I dial the GSM module I get the following http://www.kepfeltoltes.eu/view.php?filename=197DSC_0295.jpg character instead of RING string.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 6:02 am     Reply with quote

Please post your current program. The last picture of the LCD did not display 'Data...' from a printf line in the first program

Perhaps go back a couple of steps and
1) cut code to display 'Hello' on the LCD
2) same but send 'from PC', from a PC terminal program

Most LCD modules need 5 volts to operate and GSM is 3V and the PIC is running 3V as well.
If you could post a schematic of your project, post LCD module info,etc. that would be helpful.
If the LCD module is a 5V unit, running it at 3V is NOT going to work properly.

By splitting your project up this way, we can locate what is going wrong.

Jay
Dempsey



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 7:11 am     Reply with quote

Here is the current code:
Code:
   #include <18f25k20.h>
   #include <string.h>
   
   #fuses put,nolvp,noprotect,intrc_io,nowdt,
   #use delay (clock=16MHz)
   #use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7,bits=8,parity=N,stop=1,ERRORS)
   
   /////////////////////////////////////////////////////////////
   #include<flex_lcd.c>
   #include <input.c>
   
   #define BUFFER_SIZE 32
   BYTE buffer[BUFFER_SIZE];
   BYTE next_in = 0;
   BYTE next_out = 0;
   
   
   #int_rda
   void serial_isr() {
      int t;
   
      buffer[next_in]=getc();
      t=next_in;
      if(++next_in==BUFFER_SIZE)
         next_in=0;
      if(next_in==next_out)
         next_in=t;   
   }
   
   #define bkbhit (next_in!=next_out)
   
   BYTE bgetc() {
      BYTE c;
   
      while(!bkbhit) ;
      c=buffer[next_out];
      next_out=(next_out+1) % BUFFER_SIZE;
      return(c);
   }
   
   ////////////////////////////////////////////////////////////////
   void main(){
   
      lcd_init();   
      enable_interrupts(int_rda);
      enable_interrupts(global);

     do {
     //    delay_ms(10000);
   //   printf(lcd_putc,"Data:");
         while(bkbhit)
           lcd_putc( bgetc() );
      } while (TRUE);
}   
   
   
   

And the schematic of my project: http://www.kepfeltoltes.eu/view.php?filename=8432015_10_07.png
ezflyr



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

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 9:54 am     Reply with quote

Hi,

I noticed that you've got 100nf capacitors on both the PIC Rx and Tx pins. Why is that? Those capacitors would generally not be recommended!

Also, what baud rate did you use on your PC when you were communicating with the TC35 module? The default baud rate of the TC35 is apparently 19200 baud, so your selection of 9600 baud in your PIC program is not going to work!
_________________
John

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



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 10:36 am     Reply with quote

Hi,
I am using 100nF because when I touched the pins without those capacitors, the serial line was active immediatelly. About the baud rate: When I connected the TC35 to my PC I used 9600 baud on the PC side and on the TC35 side too and it was work fine. But I will try your advice (19200 baud).
ezflyr



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

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 11:21 am     Reply with quote

Hi,

If the Rx input is left 'floating', ie. there is nothing connected to it, noise can appear to the PIC as a received character. If you have a serial interrupt defined, this can be a problem. The *proper* way to deal with this is to put a 10K pull-up resistor on the Rx input only. It won't effect things during normal operation, and when the Rx pin is disconnected, it will prevent noise from triggering your interrupt. This, of course, is somewhat irrelevant, as presumably you will always have the GSM modem connected to the PIC UART... So, get rid of the capacitors for all future attempts to communicate with the GSM modem, as they are not needed and may potentially distort the Rx/Tx signals.

I should rephrase something I said in my last post, and that is *if* the TC35 is still set to the default baud rate of 19200, then a selection of 9600 in your PIC program will not work!
_________________
John

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



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 12:04 pm     Reply with quote

I see in the schematic that the LCD is 5 volts and the PIC is 3 volts. That could be part of the problem as the PIC might not send a high enough '1' to the LCD data /control lines.
Also power supply caps seem 'low' to me,generally I use 1000mfd on input, 470 on output of 7805 type regulators.

Jay
Dempsey



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 12:57 pm     Reply with quote

temtronic wrote:
I see in the schematic that the LCD is 5 volts and the PIC is 3 volts. That could be part of the problem as the PIC might not send a high enough '1' to the LCD data /control lines.
Also power supply caps seem 'low' to me,generally I use 1000mfd on input, 470 on output of 7805 type regulators.

Jay


It isn't problem. The PIC can control the LCD well. If I write any string to the LCD it will appear to the right form.
Dempsey



Joined: 24 Oct 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 1:06 pm     Reply with quote

ezflyr wrote:
Hi,

If the Rx input is left 'floating', ie. there is nothing connected to it, noise can appear to the PIC as a received character. If you have a serial interrupt defined, this can be a problem. The *proper* way to deal with this is to put a 10K pull-up resistor on the Rx input only. It won't effect things during normal operation, and when the Rx pin is disconnected, it will prevent noise from triggering your interrupt. This, of course, is somewhat irrelevant, as presumably you will always have the GSM modem connected to the PIC UART... So, get rid of the capacitors for all future attempts to communicate with the GSM modem, as they are not needed and may potentially distort the Rx/Tx signals.

I should rephrase something I said in my last post, and that is *if* the TC35 is still set to the default baud rate of 19200, then a selection of 9600 in your PIC program will not work!

I tried the 19200 baud rate and the result was: http://www.kepfeltoltes.eu/view.php?filename=261DSC_0297.jpg
ezflyr



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

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 1:34 pm     Reply with quote

Hi,

Well, there is no magic here; you are going to have to get creative and do some troubleshooting to try to resolve this issue! If it were me, I'd probably proceed as follows:

1. Disconnect the PIC from the TC35 module, and re-establish the TC35connections to the MAX232. Verify proper communications between the PC computer and the TC35 module. Note the baud rate in use!

2. Use the MAX232 on the TC35 module board to connect the PC to the PIC. This will take some creative wiring, but it should not be very hard. Use this to confirm that you can send & receive characters between the PIC and the PC.

3. For part #2, I would simplify your test program a great deal! Get rid of the serial interrupt and the circular buffer. Put a simple 'while(1)' loop in Main() that reads a character from the UART with getc, and then uses putc to echo it right back out.
_________________
John

If it's worth doing, it's worth doing in real hardware!
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