Kopi_
Newbie level 5
- Joined
- Feb 26, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,329
Hi,
I have a new prpblem. I like communicating (115200bps) between PIC18f4550 and SIM900D GSM module.
The problem is now that GSM module is communicating only 115200bps. So I was writing a C code for PIC but the program is wrong.
next code
What is a problem?
Have SIM900D a hardware reset? I was looking for the hardware reset but I am not found.
Please help.
I have a new prpblem. I like communicating (115200bps) between PIC18f4550 and SIM900D GSM module.
The problem is now that GSM module is communicating only 115200bps. So I was writing a C code for PIC but the program is wrong.
Code:
//Soros aszinkron kommunikáci és átviteli sebesség beállítása
void init_SerialKommunication(unsigned int BaudRate)
{
TXSTAbits.BRGH = 1; // high speed
BAUDCONbits.BRG16 = 1; //
switch (BaudRate)
{
case 300: SPBRGH = 0x9C; //300bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x3F; //Error[%]=0%
break;
case 1200: SPBRGH = 0x27; //1200bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x0F; //Error[%]=0%
break;
case 2400: SPBRGH = 0x13; //2400bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x87; //Error[%]=0%
break;
case 4800: SPBRGH = 0x09; //4800bps 20MHz Osc, FOSC=48MHz
SPBRG = 0xC3; //Error[%]=0%
break;
case 9600: SPBRGH = 0x04; //9600bps 20MHz Osc, FOSC=48MHz
SPBRG = 0xE1; //Error[%]=0%
break;
case 19200: SPBRGH = 0x02; //19200bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x27; //Error[%]=0%
break;
case 38400: SPBRGH = 0x01; //38400bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x39; //Error[%]=-0,5%
break;
case 57600: SPBRGH = 0x00; //57600bps 20MHz Osc, FOSC=48MHz
SPBRG = 0xD0; //Error[%]=0,16%
break;
case 115200: SPBRGH = 0x00; //115200bps 20MHz Osc, FOSC=48MHz
SPBRG = 0x67; //Error[%]=0,16%
break;
default: ;
}
TXSTAbits.SYNC = 0; // asynchronous mode
RCSTAbits.SPEN = 1; // enable serial port - configures RX/DT and TX/CK pins as serial port pins
RCSTAbits.RX9 = 0; // 8-bit receiver
TXSTAbits.TX9 = 0; // 8-bit transmission
RCSTAbits.CREN = 1; // Enables receiver
PIE1bits.RCIE = 1; // Enables the EUSART receive interrupt
TXSTAbits.TXEN = 0; // reset transmitter
TXSTAbits.TXEN = 1; // transmit enabledTXSTAbits.SYNC=0; // asynchronous mode
RCSTAbits.SPEN = 1; // enable serial port - configures RX/DT and TX/CK pins as serial port pins
TXSTAbits.TX9 = 0; // 8-bit transmission
TXSTAbits.TXEN = 0; // reset transmitter
TXSTAbits.TXEN = 1; // transmit enabled
}
next code
Code:
i = 0;
do{
while( TXSTAbits.TRMT == 0 );
TXREG=word[i];
i++;
} while (word[i] != 0x0A);
i = 0;
do
{
while ( PIR1bits.RCIF == 0 ) ; /* wait for char */
d_in[i] = RCREG;
i++;
} while (d_in[i-1]!=0x0A);
Have SIM900D a hardware reset? I was looking for the hardware reset but I am not found.
Please help.