Mega16 USART SIM300C-GSM-Modem problem

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!
I have Mega16 connected directly to SIM300C GSM-modem. The problem is that it is not working stable. I.m trying to make a voice or data call and receive 1-2 calls of 10-20 attempts. I have RX & TX connected to modem and CTS-RTS connected to each other. Also Frame Error (on Mega`s USART) occurs when trying to make a call (ATDxxxxxxxxxxx).
I have to mention that the modem and Mega16 works ok conected to PC via max232 on the same protocol and speed settings (9600, 8-N-1).
I.m using 8Mhz external crystal, 7805 stabilizer and 12V taken from ATX power block.
I suppose that some external pull-ups are required on RX,TX lines but have not found an example. If anybody have such a problem - please help me to sort it out.

Thanks !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try it with a 7.3728mhz xtal... matches the 9600 baud rate better?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But with PC is working fine !!!
So the boud rate is not the cause.
Thanks anyway !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just because the PC<->GSM baud rates match doesn't mean the AVR<->GSM baud rates match

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As i said PC to GSM is the same as AVR to PC and AVR to GSM and is 9600, 8-N-1.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The PC is probably going to be able to cope with an error in the baud sequencing much better than a GSM modem can, try using a 7.3728 MHz crystal and make sure the bauds aren't the problem before shooting off on people.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR data sheet says .2% error at 9600 bps at 8mhz. Its 0% error at 7.3278mhz. You have the fuses set right in the AVR? (easy to be using internal 1mhz rc oscillator by accident)

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

Actually if he's using 8MHz but it's "not quite right" it sounds more likely that he's inadvertently selected the 8MHz internal oscillator rather than the crystal (with 0.2% error for the xtal it SHOULD work!)

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Bob,

Actually if he's using 8MHz but it's "not quite right" it sounds more likely that he's inadvertently selected the 8MHz internal oscillator rather than the crystal (with 0.2% error for the xtal it SHOULD work!)

Cliff

I.m using CKSEL=4, CKOPT=0, SUT=1.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CodeMonkey263 wrote:
The PC is probably going to be able to cope with an error in the baud sequencing much better than a GSM modem can, try using a 7.3728 MHz crystal and make sure the bauds aren't the problem before shooting off on people.

First of all thanks for your response!
My GSM-module (SIM300C) is able (mentioned in datasheet and experimentaly proved) to communicate via UART with up to 2% errors, when my Mega16 USART settings can give me no more than %0.2.

Looks strange!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
CKSEL=4

If you mean CKSEL3..0=0100 then:
Quote:
Table 9. Internal Calibrated RC Oscillator Operating Modes
CKSEL3..0 Nominal Frequency (MHz)
0001(1) 1.0
0010 2.0
0011 4.0
0100 8.0 <<<

you *are* using the Internal Calibrated RC Oscillator @ 8MHz...?

Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MartMega wrote:
Quote:
CKSEL=4

If you mean CKSEL3..0=0100 then:
Quote:
Table 9. Internal Calibrated RC Oscillator Operating Modes
CKSEL3..0 Nominal Frequency (MHz)
0001(1) 1.0
0010 2.0
0011 4.0
0100 8.0 <<<

you *are* using the Internal Calibrated RC Oscillator @ 8MHz...?

Martin.

Right. Thanks.
Ok. Let.s try CKOPT=1, CKSEL=E, (Table 4)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nope. Now not working even with PC.
Let me show you my USART settings.

#define F_CPU 8000000UL
#define UART_BAUD  9600

void uart_init(void)
{
#if F_CPU < 2000000UL && defined(U2X)
     UCSRA = _BV(U2X);
     UBRRL = (F_CPU / (8UL * UART_BAUD)) - 1;
#else
     UBRRL = (F_CPU / (16UL * UART_BAUD)) - 1;
#endif
     UCSRB = _BV(TXEN) | _BV(RXEN);
}

U2X is not defined.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
     UBRRL = (F_CPU / (16UL * UART_BAUD)) - 1;

puts a value of 51 into UBRRL, that is ok according to the tables in the datasheet. I assume UBRRH is kept at its default of 0.

Quote:
Now not working even with PC.
Can you see if the AVR is running, and at the correct speed? I think the fuse setting of CKOPT=1, CKSEL=E is ok. Did you connect the crystal and capacitors according to Figure 12 of the datasheet?

Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Did you connect the crystal and capacitors according to Figure 12 of the datasheet?

Sure!
Quote:

Can you see if the AVR is running, and at the correct speed?

Yes. Checking it now...