Hello guys,
I have design a system that will receive text and display on the lcd but I dont know how can I receive that text, my thought is to use virtual terminal to insert the text that want to send by typing on he virtual terminal screen but when I type any character on the there is no any response. Below are my code:
/*
Code C - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
*/
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
int x;
char txt[ 16 ] ;
//GSM Modem setup
void GSM_Init( void ) ;
void GSM_Send( void ) ;
void GSM_Receive( void ) ;
void forward( ) {
Uart1_Init( 9600 ) ;
delay_ms( 100 ) ;
UART1_Write_Text( "AT\r " ) ;
UART_Write( 0x0D ) ;
delay_ms( 100 ) ;
UART1_Write_Text( "AT+CMGF=1\r " ) ;
UART_Write( 0x0D ) ;
delay_ms( 100 ) ;
UART1_Write_Text( "AT+CMGR=1" ) ;
UART_Write( 0x0D ) ;
delay_ms( 100 ) ;
delay_ms( 100 ) ;
txt[ 16 ] = UART1_Read( ) ;
UART_Write( 0x0A ) ;
UART_Write( 26 ) ;
delay_ms( 100 ) ;
}
void main( ) {
ADCON1 = 0X07 ;
TRISB = 0 ;
TRISD = 0 ;
TRISC = 0X80 ;
Lcd_Init( ) ;
Lcd_Cmd( _Lcd_Clear) ;
while ( 1 ) {
forward( ) ;
if ( UART1_Data_Ready( ) ) { // If data is received,
Lcd_Out( 1 , 1 , txt) ;
Lcd_out( 2 , 1 , "GSM" ) ; }
}
}
text on lcd from modem.PNG
74.8 KB · Views: 148
Last edited by a moderator: May 20, 2015