Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sending sms with sim900d and CodeVision AVR C compiler

Status
Not open for further replies.

Madhushani

Newbie level 5
Joined
Nov 3, 2021
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
69
Hello everyone,:)
Please help me!
I am new to this forum and this is my first post
I am using Sim900d for sending SMS with AVR microcontroller atmega 32.
I program this code that writes with CodeVision AVR C compiler, but this doesn't work.
I don't know where is wrong, can u help me?
Thanks all.

C:
/*******************************************************
This program was created by the
CodeWizardAVR V3.12 Advanced
Chip type               : ATmega32
Program type            : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 512
*******************************************************/
#include <mega32.h>
#include <delay.h>
#include <alcd.h>
#include <stdio.h>
#define ADC_VREF_TYPE ((0<<REFS1) | (0<<REFS0) | (0<<ADLAR))
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UBRRH=0x00;
UBRRL=0x67;
// ADC initialization
// ADC Clock frequency: 125.000 kHz
// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: ADC Stopped
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 3
// D5 - PORTC Bit 4
// D6 - PORTC Bit 5
// D7 - PORTC Bit 6
// Characters/line: 16
lcd_init(16);
while (1)
{
if (PIND.2 == 1)
delay_ms(100);
if (PIND.2 == 1){
PORTB.0 = 1;
lcd_gotoxy(0,0);
lcd_puts("Operation status");
lcd_puts("phase 1 fault ");
printf("\r\n");
      delay_ms(100);
      printf("AT+CMGF=1\r\n");
      delay_ms(100);
      printf("AT+CMGS=\"Phone number\"\r\n");
      delay_ms(100);
      printf ("Message Body");
      delay_ms(100);
      putchar(0x1a);
      delay_ms(100);
}
if (PIND.2 == 0)
delay_ms(100);
if (PIND.2 == 0){
PORTB.0 = 0;
lcd_gotoxy(0,0);
lcd_puts("Operation status");
lcd_puts("Normal Operation");
}
}}
 

Solution
UART settings look correct for 9600 Baud. Are you sure you have configured 16 MHz clock in the Proteus ATmega32 component settings?
Hi

"Does not work" is is meaningless for us without detailed error description.

You need to learn debugging methods.

The modem responds to each command. With this you find out what is working like expected and what is not working.

With the given information it can be anything like:
* no suitable/stable power supply for modem or microcontroller
* unsuitable voltage levels in the communication path
* wrong modem initialisation
* no or not suitable SIM card
* .... a hundred other possible mistakes

Klaus
 

Hi

"Does not work" is is meaningless for us without detailed error description.

You need to learn debugging methods.

The modem responds to each command. With this you find out what is working like expected and what is not working.

With the given information it can be anything like:
* no suitable/stable power supply for modem or microcontroller
* unsuitable voltage levels in the communication path
* wrong modem initialisation
* no or not suitable SIM card
* .... a hundred other possible mistakes

Klaus
Thank you so much for your response and cooperation. Actually, is there something wrong with the code written to send the SMS here, please can you help me fix it if there is a mistake?
 

As already written: show the Modems responses

Klaus
Before hardware implementation, I'm done with the simulation part using Proteus 8. So I use Virtual Terminal for this simulation. and I get below result. that's why I think there is an error in the code. How can I fix it? can you help me?
 

Attachments

  • 20.PNG
    20.PNG
    47.9 KB · Views: 104

Hi,

is this a real circuit problem or a simulation problem?

The weird contents of the virtual terminal may be caused by:
* baud rate mismatch
* signal polarity mismatch
* signal voltage level mismatch
* floating signal node

Klaus
 

UART settings look correct for 9600 Baud. Are you sure you have configured 16 MHz clock in the Proteus ATmega32 component settings?
 

Solution
Hi,

is this a real circuit problem or a simulation problem?

The weird contents of the virtual terminal may be caused by:
* baud rate mismatch
* signal polarity mismatch
* signal voltage level mismatch
* floating signal node

Klaus
Thank you so much for your response and cooperation. Solved my issue. Thank you for helping me.
 

Hello,

please tell what the priblem was and how you solved it.
(for other forum members with similar problem)

Klaus
 

UART settings look correct for 9600 Baud. Are you sure you have configured 16 MHz clock in the Proteus ATmega32 component settings?
Thank you so much for your response and cooperation. My problem is solved. I made a mistake there. My heartfelt thanks for reminding me of that. Thank you again and again for helping me.
 

Hello,

please tell what the priblem was and how you solved it.
(for other forum members with similar problem)

Klaus
I configured an 8 MHz clock in the Proteus ATmega32 component settings. But in Code, I configured a 16 MHz clock for ATmega32. That's why to happen an error in Proteus simulation as I mention above.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top