Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

MAX232 and AT commands

Status
Not open for further replies.

thunderfsi

Newbie level 3
Joined
Dec 16, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
Hi everyone, I'm having a problem on my circuit. I send AT commands from PIC. After they pass MAX232 "AT" turns into "_" and enter command turns into "y". I'm new to these stuff. Can anyone please help ?

Circuit: View attachment v1.3.rar

Code:
sbit LCD_RS at RC0_bit;                 // LCD_RS assigned to PORT RC0;
sbit LCD_EN at RC1_bit;                 // LCD_EN assigned to PORT RC1;
sbit LCD_D4 at RC2_bit;                 // LCD_D4 assigned to PORT RC2;
sbit LCD_D5 at RC3_bit;                 // LCD_D5 assigned to PORT RC3;
sbit LCD_D6 at RC4_bit;                 // LCD_D6 assigned to PORT RC4;
sbit LCD_D7 at RC5_bit;                 // LCD_D7 assigned to PORT RC5;

sbit LCD_RS_Direction at TRISC0_bit;    // LCD_RS assigned to TRIS C0;
sbit LCD_EN_Direction at TRISC1_bit;    // LCD_EN assigned to TRIS C1;
sbit LCD_D4_Direction at TRISC2_bit;    // LCD_D4 assigned to TRIS C2;
sbit LCD_D5_Direction at TRISC3_bit;    // LCD_D5 assigned to TRIS C3;
sbit LCD_D6_Direction at TRISC4_bit;    // LCD_D6 assigned to TRIS C4;
sbit LCD_D7_Direction at TRISC5_bit;    // LCD_D7 assigned to TRIS C5;

#define OSC 20

void main(){

     ADCON1 = 0x06; //Analog to Digital Conversion
     TRISA=0xFF;   //Set PORTA as Input
     TRISB=0x00;   //Set PORTB as Output
     TRISC=0x80; //set direction of PORTC6 as output -- TX -- transmitter //set direction of PORTC7 as input -- RX -- reciever
     TRISD =0x00;
     TRISE =0x00;

     
     RB0_bit=0;
     
     UART1_init(9600);  // Initialize UART at 9600bpm
     delay_ms(1000);
     Lcd_Init();
     Lcd_cmd(_LCD_CLEAR);
     Lcd_cmd(_LCD_CURSOR_OFF);

     UART1_Write_Text("AT");
     delay_ms(1000);
     UART1_Write(0x0D); // ENTER
     delay_ms(2000);

     Lcd_Out(1,1, "Message Sent");
     delay_ms(3000);

     Lcd_cmd(_LCD_CLEAR);
     Lcd_cmd(_LCD_CURSOR_OFF);
}
 

siongboon

Advanced Member level 1
Joined
Jan 24, 2006
Messages
425
Helped
45
Reputation
88
Reaction score
10
Trophy points
1,298
Location
Singapore
Activity points
4,069
It is very much a timing or clk problem.
Check with your scope the data rate if it is 9600 as you have set.
Then check all your clk, UART settings again.
 

Gorgon

Full Member level 6
Joined
Nov 10, 2005
Messages
345
Helped
75
Reputation
150
Reaction score
67
Trophy points
1,308
Location
Norway
Activity points
3,638
What do you read the data with, a PC?
The max232 only inverts the logic(logic1=-v and logic0=+v), and does not add anything to the data itself.
If you read one character for the two sent, there is a mismatch in baudrate between the sender and the receiver.
 

Surender Reddy

Full Member level 2
Joined
Jan 28, 2012
Messages
130
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
Bangalore, India
Activity points
2,189
The problem should be with baudrate mismatch of the PIC & the PC.
For PIC use 9600 and check in PC for 9600, baudrate should match.....
check it once.......
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top