View previous topic :: View next topic |
Author |
Message |
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
Problem with RS232 found, but not solution |
Posted: Sat Jun 11, 2011 9:56 am |
|
|
Hello,
I have a SIMCOM900B GSM module connected with the pic18F2550 via RS232.
It works fine.
The problem is, the start from the SIMCOM900B Module. To start PIN_A2 is going high, then wait 1.2 seconds, PIN_A2 low, wait 2.2 seconds. The the module is ready and the RS232 from the module is also ready and sends Information.
If I start the module with a switch, no problem. But when I start the module with the pic like:
Code: | void powerup_SIM900B(void){
output_high(SIM900BPWR);
delay_ms(1200);
output_low(SIM900BPWR);
delay_ms(2200);
} |
The PIC RXD is hanging up. When i disconnect the RX PIN (C7) before I start the module and connect RX after start from module it works.
So there must be a signal in the delay_ms() on RX that the RXD PIN is hanging up.
Is there a posibility to disable RS232 or the PIN and enable it later?
I have solved it with a relay, but not my favorite...
Thanks
Volker |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Sat Jun 11, 2011 2:41 pm |
|
|
Just add 'errors' to your RS232 declaration.
The module probably drops the RS232 line at some point in the wake up. This results in the internal RS232 buffer overflowing (only two characters), which hangs the RS232 receive, unless you add code to clear this. Adding the keyword 'errors' to the RS232 declaration, makes the compiler automatically do this, and the RS232 will then still work (probably have a couple of garbage characters you should read).
Best Wishes |
|
|
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
|
Posted: Sun Jun 12, 2011 8:17 am |
|
|
Hello,
I have added the 'error', but no effect!
In the help file is describe the rs232_errors variable. But the compiler is not knowing this and throw an compile error.
Here ist my rs232 definition:
Code: | #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, errors) |
any other ideas? How can I clear this manual?
Thanks
Volker |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9239 Location: Greensville,Ontario
|
|
Posted: Sun Jun 12, 2011 9:13 am |
|
|
Please post a small, compilable code that shows the problem, include the PIC type and Compiler version as well. |
|
|
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
|
Posted: Sun Jun 12, 2011 9:59 am |
|
|
Hello,
with the ex_usb_serial example I can generate the error.
PIC is 18F2550 and Compiler Version is 4.088.
Could it be a compiler problem? Perhaps I should get the newest verison!?
I have read in some threads compiler throw a warning when use 'errors'. But I cant's see a warning! Also the compiler not known the 'RS232_ERRORS' variable!
Thaks
Volker |
|
|
Desert Leo
Joined: 08 Jun 2011 Posts: 7
|
|
Posted: Sun Jun 12, 2011 10:43 am |
|
|
Volker, are you sure that when PIC RX pin is disconnected during power up of GSM module everything is OK. Or it is PIC TX pin? Some GSM modules hungs-up when voltage is aplied to input pin BEFORE power on.
Also check for some "hallo" message from GSM module to UART after power on. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Jun 13, 2011 2:00 am |
|
|
This is a very good point.
First, on the RS232_ERRORS. Two things here. It is possibly that you have the warning this raises 'turned off' in the compiler settings.
Second, on not being able to find the variable. Is it possible you have #CASE selected?. If so, are you sure of the case of the RS232_ERRORS variable?.
Then on the comment from Desert Leo.
Configure the RS232 with:
#use rs232(baud=0,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, errors)
This sets up the UART, but leaves it turned off.
Then after the initialisation sequence if sent to the modem, use:
setup_uart(9600);
which will turn it on, and set the baud rate to 9600bps.
The UART pins will remain as inputs, till this occurs (unless you access then yourself).
Best Wishes |
|
|
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
|
Posted: Mon Jun 13, 2011 3:40 am |
|
|
@Desert Leo.
Yes, it is the RX pin from PIC. When I pull off this pin and connect it when the module is ready, it works. The module is not hanging up.
@Ttelmah,
I not use the #CASE statement. I get any other Warnings like 'Condition always TRUE' and so on.
I have tried 'RS232_ERRORS' and 'rs232_errors', same problem.
So I think there is everything wrong with the compiler.
It seems that the 'errors' in rs232 definition has no effect.
Where is the RS232_ERRORS defined?
Thanks
Volker |
|
|
Desert Leo
Joined: 08 Jun 2011 Posts: 7
|
|
Posted: Mon Jun 13, 2011 5:09 am |
|
|
Proceed as described in Ttelmah's last post.
In your code put the row "setup_uart(9600);" AFTER GSM power on command. |
|
|
|