# AT+CPIN? causes ERROR on microcontroller, OK on PC Terminal

**URL:** <https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639>\
**Category:** Legacy AirPrime modules\
**Created:** [October 9, 2007, 1:42pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639 "2007-10-09T13:42:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 9, 2007, 1:42pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/1 "2007-10-09T13:42:21Z")

</div>

Hi,

I want to access the GS64 integrated on CEPAGs GS64T via RS232 by the ATMEL ATMEGA128 microcontroller. Therefor I use a cable with four lines: Rx, Tx, RTS and CTS … it’s the only difference in communication to the PC I can imagine, where all lines are connected.

When I start the Modem, an initial “AT_E2SDR?" is sent for checking the SIM-Status, if the presence of a SIM-card is reported, the PIN should be sent. Before sending, the MC asks which type of PIN is needed by sending an “AT+CPIN?” … and there the fun starts. The MC always gets ERROR back, if I try the very same commands by a PC based Terminal, everything is fine. All the other commands work well on the MC, the only commands working differently are “AT+CPIN?”, “AT+CPIN=“xxxx”” and as a try "AT_E2SSN” Somehow commands related to the SIM-Card, except for “AT\*E2SDR?” are corrupted when being used by the MC.

What might be the cause?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 9, 2007, 3:04pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/2 "2007-10-09T15:04:13Z")

</div>

> [@docvasi](#):
>
> I use a cable with four lines: Rx, Tx, RTS and CTS … it’s the only difference in communication to the PC I can imagine, where all lines are connected.

Well, you could easily check that by using a 4-line cable with your PC, surely?

Are you certain that all the settings are the same - flow control, stop bits, parity, etc, etc…?

Does your microcontroller have a proper RS232 interface - ie proper transceivers (MAX232 or whatever)?

> [@](#):
>
> The MC always gets ERROR back, if I try the very same commands by a PC based Terminal, everything is fine.

Are you typing the commands manually on the terminal?  
If so, the timing will certainly be different!

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 9, 2007, 3:40pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/3 "2007-10-09T15:40:57Z")

</div>

Hi,

I just made a cable with only Tx, Rx, RTS, CTS, GND and guess what … the PC got the same error. By connecting the DTR-pin the problem could be solved. The only thing I have to figure out now is, how to actually use the DTR-line correctly.

I already used a four line MAX232 where all four lines are in use. I hope it works with a static 1 on DTR or might be connecting DTR and DSR a better (or worse) idea?

â‚¬dit: The program sends the commands, from the terminal they come manually.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 9, 2007, 10:46pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/4 "2007-10-09T22:46:48Z")

</div>

> [@docvasi](#):
>
> The only thing I have to figure out now is, how to actually use the DTR-line correctly.

What does the module’s datasheet say?

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 10, 2007, 9:43am UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/5 "2007-10-10T09:43:38Z")

</div>

The technical Datasheet indicates, that only CTS and RTS are really needed for communication, that the needed signal is active low and that the behaviour of DTR and DSR can be configured manually. AT command manual reveals now, that by default, the DTR-Pin is ignored.

And fun fact: letting the modem rest for a night made the connection of the DTR Pin obsolete, at least with the PC terminal, the MC carries on getting the ERROR-Message … would have been boring anyway if it just worked.

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 10, 2007, 2:59pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/6 "2007-10-10T14:59:18Z")

</div>

I’ve set the DTR to 1 by pulling it to active low with the V- of the ST3232 converter. Nothing. Still the MC gets the errors when using SIM-related commands, the PC terminal meanwhile works fine without DTR line … I’m really running out of ideas.

â‚¬dit: Might the voltage level of +5/-5 V of the ST3232 be the problem? Isn’t it +12/-12 V with the PC?

â‚¬dit 2: I just measured +6/-6 V on the COM-Port of my Notebook

---

<div class="post-metadata">

**Author:** ![ToF](https://avatars.discourse-cdn.com/v4/letter/t/db5fbb/32.png) [@ToF](https://forum.sierrawireless.com/u/ToF)\
**Post date:** [October 12, 2007, 2:02pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/7 "2007-10-12T14:02:19Z")

</div>

Have you tried to get the error number threw AT+CMEE, in order to understand your error…

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 13, 2007, 12:17pm UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/8 "2007-10-13T12:17:38Z")

</div>

Funny, latest thing I came up with yesterday =) Errornumber is 3 “operation not allowed” … and as a bonus, I found out that my lab mate designed the interface board a little faultily … wrong enough to blast the audio interface on the GS64 Module. One feature gone, two left. That was the point I decided not to take the whole project personally … then this little terrorist modem would have won O\_O  
Thank God it’s only for my bachelor thesis … enough of this. It’s weekend!

â‚¬dit: AT+CEER throws “failure cause 94” any ideas? Haven’t found it yet.

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 15, 2007, 10:13am UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/9 "2007-10-15T10:13:38Z")

</div>

Finally someone competent at Cepag who talks to the customer =) So, it appears, that the SIM-Card needs some time to initialize before becoming available to commands. The PIN-command was simply given too early. Feels good having solved a problem, sucks having wasted a whole week on it.

Thanks anyway,

Thilo

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 15, 2007, 11:34am UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/10 "2007-10-15T11:34:59Z")

</div>

> [@docvasi](#):
>
> The PIN-command was simply given too early. Feels good having solved a problem, sucks having wasted a whole week on it.

Well, I did suggest timing to you in my very first reply! 8)  
[wavecom.com/modules/movie/sc … ght=timing](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=1742&highlight=timing)

The Wavecom AT Commands manual has a section at the end that lists what commands depend on things like SIM state - I don’t know if the GS64 documentation (being originally Ericsson) has something similar…?

Note that the time required for a SIM to initialise is undefined, and can differ between different SIMs - so you need to be sure to allow plenty of time!

Again, Wavecom have +WIND: indications that advise SIM state - I don’t know if the GS64 has anything similar?

---

<div class="post-metadata">

**Author:** ![docvasi](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@docvasi](https://forum.sierrawireless.com/u/docvasi)\
**Post date:** [October 16, 2007, 10:11am UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/11 "2007-10-16T10:11:20Z")

</div>

I know =/ I was so fixed on communication that I totally forgot about the needs of the module. Cepag support said “You have to realize that this is only a dumb modem.” That’s the way I see it now … dumb modem! I couldn’t test the +WIND command yet, the AT manual knows nothing about it, the list at the end of it is just all the commands in alphabetic order.

Anyway, I have a new problem … time for a new thread. Later when I’m at the university.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 16, 2007, 11:01am UTC](https://forum.sierrawireless.com/t/at-cpin-causes-error-on-microcontroller-ok-on-pc-terminal/1639/12 "2007-10-16T11:01:49Z")

</div>

> [@docvasi](#):
>
> I couldn’t test the +WIND command yet, the AT manual knows nothing about it

Like I said: it’s a Wavecom special - probably not available on the GS64, as that’s essentially a Sony-Ericsson module.  
(Wavecom “inherited” it when they bought-out the Sony-Ericsson M2M business)

My question was, does the GS64 offer anything equivalent ❓
